vla: enable sizeof operator for indirection
This patch enables the sizeof operator for indirections: 1| void foo (size_t n) { 2| int vla[n]; 3| int *vla_ptr = &vla; 4| } (gdb) p sizeof(*vla_ptr) yields sizeof (size_t) * n. * eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect value and retrieve the dynamic type size.
This commit is contained in:
parent
26cb189f8b
commit
04b19544ef
|
@ -1,3 +1,8 @@
|
||||||
|
2014-04-11 Sanimir Agovic <sanimir.agovic@intel.com>
|
||||||
|
|
||||||
|
* eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect
|
||||||
|
value and retrieve the dynamic type size.
|
||||||
|
|
||||||
2014-04-11 Sanimir Agovic <sanimir.agovic@intel.com>
|
2014-04-11 Sanimir Agovic <sanimir.agovic@intel.com>
|
||||||
|
|
||||||
* eval.c (evaluate_subexp_for_sizeof) <OP_VAR_VALUE>: If the type
|
* eval.c (evaluate_subexp_for_sizeof) <OP_VAR_VALUE>: If the type
|
||||||
|
|
|
@ -3026,6 +3026,8 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
|
||||||
&& TYPE_CODE (type) != TYPE_CODE_ARRAY)
|
&& TYPE_CODE (type) != TYPE_CODE_ARRAY)
|
||||||
error (_("Attempt to take contents of a non-pointer value."));
|
error (_("Attempt to take contents of a non-pointer value."));
|
||||||
type = check_typedef (TYPE_TARGET_TYPE (type));
|
type = check_typedef (TYPE_TARGET_TYPE (type));
|
||||||
|
if (is_dynamic_type (type))
|
||||||
|
type = value_type (value_ind (val));
|
||||||
return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
|
return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
|
||||||
|
|
||||||
case UNOP_MEMVAL:
|
case UNOP_MEMVAL:
|
||||||
|
|
Loading…
Reference in New Issue