[PATCH v6 10/15] vla: evaluate operand of sizeof if its type is a vla

Joel Brobecker brobecker@adacore.com
Thu Apr 10 14:31:00 GMT 2014


> 2014-02-05  Sanimir Agovic  <sanimir.agovic@intel.com>
>             Keven Boell <keven.boell@intel.com>
> 
> 	* eval.c (evaluate_subexp_for_sizeof): Add enum noside argument.
> 	(evaluate_subexp_standard): Pass noside argument.
> 	(evaluate_subexp_for_sizeof) <BINOP_SUBSCRIPT>: Handle subscript case
> 	if noside equals EVAL_NORMAL. If the subscript yields a vla type
> 	re-evaluate subscript operation with EVAL_NORMAL to enable sideffects.
> 	* gdbtypes.c (resolve_dynamic_bounds): Mark bound as evaluated.
> 	* gdbtypes.h (enum range_flags): Add RANGE_EVALUATED case.
> 
> testsuite/gdb.base/
> 
> 	* vla-sideeffect.c: New file.
> 	* vla-sideeffect.exp: New file.

Approved with some minor trivial modifications.

>  /* Evaluate a subexpression of EXP, at index *POS,
>     and return a value for the size of that subexpression.
> -   Advance *POS over the subexpression.  */
> +   Advance *POS over the subexpression. If NOSIDE is EVAL_NORMAL
                                       ^^^^^^^
Minor style nit: Two spaces after a period ("If NOSIDE")

> +		  if (TYPE_RANGE_DATA (type)->flag_bound_evaluated)
> +		    {
> +		      val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_NORMAL);
> +		      return value_from_longest
> +			(size_type, (LONGEST)TYPE_LENGTH (value_type (val)));

I missed this one in the my first review, but there should be a space
after "(LONGEST)".

> +set sizeof_vla [ expr "10" * "$sizeof_int" ]
> +
> +gdb_test "print sizeof (vla1\[i++\])" "= ${sizeof_int}" \

Just to be consistent, let's add a space before the "=" sign.

> +         "print sizeof (vla1\[i++\])"

Thanks,
-- 
Joel



More information about the Gdb-patches mailing list