[D] Implement looking up members of D enums.
In D, all named enums are explicitly scoped (the C++ equivalent of enum class) so they should be handled as such in the language-specific symbol lookup routines. However so as to support D compilers that don't emit enums as DW_AT_enum_class, need to make sure that appropriate checks for TYPE_DECLARED_CLASS are done. gdb/ChangeLog * d-exp.y (type_aggregate_p): New function. (PrimaryExpression : TypeExp '.' IdentifierExp): Use it. (classify_inner_name): Likewise. * d-namespace.c (d_lookup_nested_symbol): Handle TYPE_CODE_ENUM.
This commit is contained in:
parent
ad89c2aa67
commit
7f3706ebfe
3 changed files with 24 additions and 3 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2015-08-17 Iain Buclaw <ibuclaw@gdcproject.org>
|
||||||
|
|
||||||
|
* d-exp.y (type_aggregate_p): New function.
|
||||||
|
(PrimaryExpression : TypeExp '.' IdentifierExp): Use it.
|
||||||
|
(classify_inner_name): Likewise.
|
||||||
|
* d-namespace.c (d_lookup_nested_symbol): Handle TYPE_CODE_ENUM.
|
||||||
|
|
||||||
2015-08-15 Doug Evans <xdje42@gmail.com>
|
2015-08-15 Doug Evans <xdje42@gmail.com>
|
||||||
|
|
||||||
* psymtab.c (add_psymbol_to_bcache): Remove "val" arg. All callers
|
* psymtab.c (add_psymbol_to_bcache): Remove "val" arg. All callers
|
||||||
|
|
19
gdb/d-exp.y
19
gdb/d-exp.y
|
@ -126,6 +126,8 @@ static int yylex (void);
|
||||||
|
|
||||||
void yyerror (char *);
|
void yyerror (char *);
|
||||||
|
|
||||||
|
static int type_aggregate_p (struct type *);
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/* Although the yacc "value" of an expression is not used,
|
/* Although the yacc "value" of an expression is not used,
|
||||||
|
@ -554,9 +556,7 @@ PrimaryExpression:
|
||||||
|
|
||||||
/* Check if the qualified name resolves as a member
|
/* Check if the qualified name resolves as a member
|
||||||
of an aggregate or an enum type. */
|
of an aggregate or an enum type. */
|
||||||
if (!(TYPE_CODE (type) == TYPE_CODE_STRUCT
|
if (!type_aggregate_p (type))
|
||||||
|| TYPE_CODE (type) == TYPE_CODE_UNION
|
|
||||||
|| TYPE_CODE (type) == TYPE_CODE_ENUM))
|
|
||||||
error (_("`%s' is not defined as an aggregate type."),
|
error (_("`%s' is not defined as an aggregate type."),
|
||||||
TYPE_SAFE_NAME (type));
|
TYPE_SAFE_NAME (type));
|
||||||
|
|
||||||
|
@ -695,6 +695,17 @@ BasicType:
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
/* 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_ENUM
|
||||||
|
&& TYPE_DECLARED_CLASS (type)));
|
||||||
|
}
|
||||||
|
|
||||||
/* Take care of parsing a number (anything that starts with a digit).
|
/* Take care of parsing a number (anything that starts with a digit).
|
||||||
Set yylval and return the token type; update lexptr.
|
Set yylval and return the token type; update lexptr.
|
||||||
LEN is the number of characters in it. */
|
LEN is the number of characters in it. */
|
||||||
|
@ -1440,6 +1451,8 @@ classify_inner_name (struct parser_state *par_state,
|
||||||
return classify_name (par_state, block);
|
return classify_name (par_state, block);
|
||||||
|
|
||||||
type = check_typedef (context);
|
type = check_typedef (context);
|
||||||
|
if (!type_aggregate_p (type))
|
||||||
|
return ERROR;
|
||||||
|
|
||||||
copy = copy_name (yylval.ssym.stoken);
|
copy = copy_name (yylval.ssym.stoken);
|
||||||
yylval.ssym.sym = d_lookup_nested_symbol (type, copy, block);
|
yylval.ssym.sym = d_lookup_nested_symbol (type, copy, block);
|
||||||
|
|
|
@ -308,6 +308,7 @@ d_lookup_nested_symbol (struct type *parent_type,
|
||||||
{
|
{
|
||||||
case TYPE_CODE_STRUCT:
|
case TYPE_CODE_STRUCT:
|
||||||
case TYPE_CODE_UNION:
|
case TYPE_CODE_UNION:
|
||||||
|
case TYPE_CODE_ENUM:
|
||||||
case TYPE_CODE_MODULE:
|
case TYPE_CODE_MODULE:
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue