X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gdb%2Fc-exp.y;h=7339ee8cb701d225284f8480a71717a171fd6979;hb=cbda93a56a0af8d7787ff091caad64af1b2bd085;hp=f39391c8124fc65a1ac45639a257a2111504043f;hpb=245a5f0b7429b03566eb3f57a92544218f33393c;p=platform%2Fupstream%2Fbinutils.git diff --git a/gdb/c-exp.y b/gdb/c-exp.y index f39391c..7339ee8 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -36,7 +36,6 @@ %{ #include "defs.h" -#include #include #include "expression.h" #include "value.h" @@ -50,7 +49,6 @@ #include "block.h" #include "cp-support.h" #include "dfp.h" -#include "gdb_assert.h" #include "macroscope.h" #include "objc-lang.h" #include "typeprint.h" @@ -129,6 +127,8 @@ static int yylex (void); void yyerror (char *); +static int type_aggregate_p (struct type *); + %} /* Although the yacc "value" of an expression is not used, @@ -156,7 +156,7 @@ void yyerror (char *); struct ttype tsym; struct symtoken ssym; int voidval; - struct block *bval; + const struct block *bval; enum exp_opcode opcode; struct stoken_vector svec; @@ -986,9 +986,7 @@ qualified_name: TYPENAME COLONCOLON name { struct type *type = $1.type; CHECK_TYPEDEF (type); - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION - && TYPE_CODE (type) != TYPE_CODE_NAMESPACE) + if (!type_aggregate_p (type)) error (_("`%s' is not defined as an aggregate type."), TYPE_SAFE_NAME (type)); @@ -1004,9 +1002,7 @@ qualified_name: TYPENAME COLONCOLON name char *buf; CHECK_TYPEDEF (type); - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION - && TYPE_CODE (type) != TYPE_CODE_NAMESPACE) + if (!type_aggregate_p (type)) error (_("`%s' is not defined as an aggregate type."), TYPE_SAFE_NAME (type)); buf = alloca ($4.length + 2); @@ -1701,6 +1697,18 @@ operator_stoken (const char *op) return st; }; +/* Return true if the type is aggregate-like. */ + +static int +type_aggregate_p (struct type *type) +{ + return (TYPE_CODE (type) == TYPE_CODE_STRUCT + || TYPE_CODE (type) == TYPE_CODE_UNION + || TYPE_CODE (type) == TYPE_CODE_NAMESPACE + || (TYPE_CODE (type) == TYPE_CODE_ENUM + && TYPE_DECLARED_CLASS (type))); +} + /* Validate a parameter typelist. */ static void @@ -1816,7 +1824,7 @@ parse_number (struct parser_state *par_state, } /* Handle base-switching prefixes 0x, 0t, 0d, 0 */ - if (p[0] == '0') + if (p[0] == '0' && len > 1) switch (p[1]) { case 'x': @@ -3000,9 +3008,7 @@ classify_inner_name (struct parser_state *par_state, return classify_name (par_state, block, 0); type = check_typedef (context); - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION - && TYPE_CODE (type) != TYPE_CODE_NAMESPACE) + if (!type_aggregate_p (type)) return ERROR; copy = copy_name (yylval.ssym.stoken);