Copy over fix for fetching dynamic type of a reference from python side.
[deliverable/binutils-gdb.git] / gdb / c-exp.y
index fc798079e3b1571c7ea11e28b317e32051888fbe..f39391c8124fc65a1ac45639a257a2111504043f 100644 (file)
@@ -787,14 +787,22 @@ exp       :       SELECTOR '(' name ')'
        ;
 
 exp    :       SIZEOF '(' type ')'     %prec UNARY
-                       { write_exp_elt_opcode (pstate, OP_LONG);
+                       { struct type *type = $3;
+                         write_exp_elt_opcode (pstate, OP_LONG);
                          write_exp_elt_type (pstate, lookup_signed_typename
                                              (parse_language (pstate),
                                               parse_gdbarch (pstate),
                                               "int"));
-                         CHECK_TYPEDEF ($3);
+                         CHECK_TYPEDEF (type);
+
+                           /* $5.3.3/2 of the C++ Standard (n3290 draft)
+                              says of sizeof:  "When applied to a reference
+                              or a reference type, the result is the size of
+                              the referenced type."  */
+                         if (TYPE_CODE (type) == TYPE_CODE_REF)
+                           type = check_typedef (TYPE_TARGET_TYPE (type));
                          write_exp_elt_longcst (pstate,
-                                                (LONGEST) TYPE_LENGTH ($3));
+                                                (LONGEST) TYPE_LENGTH (type));
                          write_exp_elt_opcode (pstate, OP_LONG); }
        ;
 
This page took 0.023688 seconds and 4 git commands to generate.