Commit 84d901be by Akim Demaille Committed by Zack Weinberg

c-parse.in (initelt: identifier ':' initval): Add an empty action to fix a type clash.

2002-06-19  Akim Demaille  <akim@epita.fr>

	* c-parse.in (initelt: identifier ':' initval): Add an empty
	action to fix a type clash.
	(aliasdecl, classdef): Add the missing closing `;'.
	Whitespace changes.
	* gengtype-yacc.y (typedef_struct): Add an empty action to preevnt
	$$ = $1 type clashes.

cp:
	* parse.y (TYPENAME): Rename as tTYPENAME to avoid the clash with
	decl.h's TYPENAME.
	* spew.c, lex.c: Adjust.
	* parse.y (explicit_instantiation): Add empty action to override
	the default $$ = $1 where it introduces a type clash.

From-SVN: r54811
parent ef40bc65
2002-06-19 Akim Demaille <akim@epita.fr>
* c-parse.in (initelt: identifier ':' initval): Add an empty
action to fix a type clash.
(aliasdecl, classdef): Add the missing closing `;'.
Whitespace changes.
* gengtype-yacc.y (typedef_struct): Add an empty action to preevnt
$$ = $1 type clashes.
2002-06-19 Eric Christopher <echristo@redhat.com> 2002-06-19 Eric Christopher <echristo@redhat.com>
* config/mips/mips.c (symbol_operand): New function. * config/mips/mips.c (symbol_operand): New function.
......
...@@ -1544,6 +1544,7 @@ initelt: ...@@ -1544,6 +1544,7 @@ initelt:
if (pedantic) if (pedantic)
pedwarn ("obsolete use of designated initializer with `:'"); } pedwarn ("obsolete use of designated initializer with `:'"); }
initval initval
{}
| initval | initval
; ;
...@@ -2708,12 +2709,14 @@ classdecl: ...@@ -2708,12 +2709,14 @@ classdecl:
{ {
objc_declare_class ($2); objc_declare_class ($2);
} }
;
aliasdecl: aliasdecl:
ALIAS identifier identifier ';' ALIAS identifier identifier ';'
{ {
objc_declare_alias ($2, $3); objc_declare_alias ($2, $3);
} }
;
classdef: classdef:
INTERFACE identifier protocolrefs '{' INTERFACE identifier protocolrefs '{'
......
2002-06-19 Akim Demaille <akim@epita.fr>
* parse.y (TYPENAME): Rename as tTYPENAME to avoid the clash with
decl.h's TYPENAME.
* spew.c, lex.c: Adjust.
* parse.y (explicit_instantiation): Add empty action to override
the default $$ = $1 where it introduces a type clash.
2002-06-14 Jason Merrill <jason@redhat.com> 2002-06-14 Jason Merrill <jason@redhat.com>
* semantics.c (begin_for_stmt): Push the 'for' scope before * semantics.c (begin_for_stmt): Push the 'for' scope before
......
...@@ -86,10 +86,11 @@ extern YYSTYPE yylval; /* the semantic value of the */ ...@@ -86,10 +86,11 @@ extern YYSTYPE yylval; /* the semantic value of the */
int warn_traditional = 0; int warn_traditional = 0;
int flag_digraphs = 1; int flag_digraphs = 1;
/* the declaration found for the last IDENTIFIER token read in. /* the declaration found for the last IDENTIFIER token read in. yylex
yylex must look this up to detect typedefs, which get token type TYPENAME, must look this up to detect typedefs, which get token type
so it is left around in case the identifier is not a typedef but is tTYPENAME, so it is left around in case the identifier is not a
used in a context which makes it a reference to a variable. */ typedef but is used in a context which makes it a reference to a
variable. */
tree lastiddecl; tree lastiddecl;
/* Array for holding counts of the numbers of tokens seen. */ /* Array for holding counts of the numbers of tokens seen. */
...@@ -692,7 +693,7 @@ yyprint (file, yychar, yylval) ...@@ -692,7 +693,7 @@ yyprint (file, yychar, yylval)
switch (yychar) switch (yychar)
{ {
case IDENTIFIER: case IDENTIFIER:
case TYPENAME: case tTYPENAME:
case TYPESPEC: case TYPESPEC:
case PTYPENAME: case PTYPENAME:
case PFUNCNAME: case PFUNCNAME:
...@@ -914,7 +915,7 @@ check_for_missing_semicolon (type) ...@@ -914,7 +915,7 @@ check_for_missing_semicolon (type)
if ((yychar > 255 if ((yychar > 255
&& yychar != SCSPEC && yychar != SCSPEC
&& yychar != IDENTIFIER && yychar != IDENTIFIER
&& yychar != TYPENAME && yychar != tTYPENAME
&& yychar != CV_QUALIFIER && yychar != CV_QUALIFIER
&& yychar != SELFNAME) && yychar != SELFNAME)
|| yychar == 0 /* EOF */) || yychar == 0 /* EOF */)
......
...@@ -283,7 +283,7 @@ check_class_key (key, aggr) ...@@ -283,7 +283,7 @@ check_class_key (key, aggr)
/* All identifiers that are declared typedefs in the current block. /* All identifiers that are declared typedefs in the current block.
In some contexts, they are treated just like IDENTIFIER, In some contexts, they are treated just like IDENTIFIER,
but they can also serve as typespecs in declarations. */ but they can also serve as typespecs in declarations. */
%token TYPENAME %token tTYPENAME
%token SELFNAME %token SELFNAME
/* A template function. */ /* A template function. */
...@@ -345,7 +345,7 @@ check_class_key (key, aggr) ...@@ -345,7 +345,7 @@ check_class_key (key, aggr)
%nonassoc IF %nonassoc IF
%nonassoc ELSE %nonassoc ELSE
%left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD ATTRIBUTE %left IDENTIFIER PFUNCNAME tTYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD ATTRIBUTE
%left '{' ',' ';' %left '{' ',' ';'
...@@ -375,7 +375,7 @@ check_class_key (key, aggr) ...@@ -375,7 +375,7 @@ check_class_key (key, aggr)
%type <code> unop %type <code> unop
%type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist %type <ttype> identifier IDENTIFIER tTYPENAME CONSTANT expr nonnull_exprlist
%type <ttype> PFUNCNAME maybe_identifier %type <ttype> PFUNCNAME maybe_identifier
%type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
%type <ttype> expr_no_commas expr_no_comma_rangle %type <ttype> expr_no_commas expr_no_comma_rangle
...@@ -1023,7 +1023,7 @@ member_init: ...@@ -1023,7 +1023,7 @@ member_init:
identifier: identifier:
IDENTIFIER IDENTIFIER
| TYPENAME | tTYPENAME
| SELFNAME | SELFNAME
| PTYPENAME | PTYPENAME
| NSNAME | NSNAME
...@@ -1060,17 +1060,21 @@ explicit_instantiation: ...@@ -1060,17 +1060,21 @@ explicit_instantiation:
{ do_type_instantiation ($4.t, $1, 1); { do_type_instantiation ($4.t, $1, 1);
yyungetc (';', 1); } yyungetc (';', 1); }
end_explicit_instantiation end_explicit_instantiation
{}
| SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
declarator declarator
{ tree specs = strip_attrs ($4.t); { tree specs = strip_attrs ($4.t);
do_decl_instantiation (specs, $5, $1); } do_decl_instantiation (specs, $5, $1); }
end_explicit_instantiation end_explicit_instantiation
{}
| SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
{ do_decl_instantiation (NULL_TREE, $4, $1); } { do_decl_instantiation (NULL_TREE, $4, $1); }
end_explicit_instantiation end_explicit_instantiation
{}
| SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
{ do_decl_instantiation (NULL_TREE, $4, $1); } { do_decl_instantiation (NULL_TREE, $4, $1); }
end_explicit_instantiation end_explicit_instantiation
{}
; ;
begin_explicit_instantiation: begin_explicit_instantiation:
...@@ -1089,7 +1093,7 @@ template_type: ...@@ -1089,7 +1093,7 @@ template_type:
PTYPENAME '<' template_arg_list_opt template_close_bracket PTYPENAME '<' template_arg_list_opt template_close_bracket
finish_template_type_ finish_template_type_
{ $$ = $5; } { $$ = $5; }
| TYPENAME '<' template_arg_list_opt template_close_bracket | tTYPENAME '<' template_arg_list_opt template_close_bracket
finish_template_type_ finish_template_type_
{ $$ = $5; } { $$ = $5; }
| self_template_type | self_template_type
...@@ -1557,7 +1561,7 @@ object_template_id: ...@@ -1557,7 +1561,7 @@ object_template_id:
unqualified_id: unqualified_id:
notype_unqualified_id notype_unqualified_id
| TYPENAME | tTYPENAME
| SELFNAME | SELFNAME
; ;
...@@ -2770,7 +2774,7 @@ after_type_component_declarator0: ...@@ -2770,7 +2774,7 @@ after_type_component_declarator0:
after_type_declarator maybeasm maybe_attribute maybe_init after_type_declarator maybeasm maybe_attribute maybe_init
{ $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups, { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
$3, $2, $4); } $3, $2, $4); }
| TYPENAME ':' expr_no_commas maybe_attribute | tTYPENAME ':' expr_no_commas maybe_attribute
{ $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups, { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
$4, $3); } $4, $3); }
; ;
...@@ -2793,7 +2797,7 @@ notype_component_declarator0: ...@@ -2793,7 +2797,7 @@ notype_component_declarator0:
after_type_component_declarator: after_type_component_declarator:
after_type_declarator maybeasm maybe_attribute maybe_init after_type_declarator maybeasm maybe_attribute maybe_init
{ $$ = parse_field ($1, $3, $2, $4); } { $$ = parse_field ($1, $3, $2, $4); }
| TYPENAME ':' expr_no_commas maybe_attribute | tTYPENAME ':' expr_no_commas maybe_attribute
{ $$ = parse_bitfield ($1, $4, $3); } { $$ = parse_bitfield ($1, $4, $3); }
; ;
...@@ -3065,7 +3069,7 @@ functional_cast: ...@@ -3065,7 +3069,7 @@ functional_cast:
; ;
type_name: type_name:
TYPENAME tTYPENAME
| SELFNAME | SELFNAME
| template_type %prec EMPTY | template_type %prec EMPTY
; ;
...@@ -3089,7 +3093,7 @@ nested_name_specifier: ...@@ -3089,7 +3093,7 @@ nested_name_specifier:
/* Why the @#$%^& do type_name and notype_identifier need to be expanded /* Why the @#$%^& do type_name and notype_identifier need to be expanded
inline here?!? (jason) */ inline here?!? (jason) */
nested_name_specifier_1: nested_name_specifier_1:
TYPENAME SCOPE tTYPENAME SCOPE
{ {
if (TREE_CODE ($1) == IDENTIFIER_NODE) if (TREE_CODE ($1) == IDENTIFIER_NODE)
{ {
...@@ -3175,7 +3179,7 @@ typename_sub1: ...@@ -3175,7 +3179,7 @@ typename_sub1:
/* This needs to return a TYPE_DECL for simple names so that we don't /* This needs to return a TYPE_DECL for simple names so that we don't
forget what name was used. */ forget what name was used. */
typename_sub2: typename_sub2:
TYPENAME SCOPE tTYPENAME SCOPE
{ {
if (TREE_CODE ($1) != TYPE_DECL) if (TREE_CODE ($1) != TYPE_DECL)
$$ = lastiddecl; $$ = lastiddecl;
...@@ -3613,7 +3617,7 @@ label_colon: ...@@ -3613,7 +3617,7 @@ label_colon:
{ finish_label_stmt ($1); } { finish_label_stmt ($1); }
| PTYPENAME ':' | PTYPENAME ':'
{ finish_label_stmt ($1); } { finish_label_stmt ($1); }
| TYPENAME ':' | tTYPENAME ':'
{ finish_label_stmt ($1); } { finish_label_stmt ($1); }
| SELFNAME ':' | SELFNAME ':'
{ finish_label_stmt ($1); } { finish_label_stmt ($1); }
......
...@@ -161,10 +161,11 @@ static enum cpp_ttype last_token; ...@@ -161,10 +161,11 @@ static enum cpp_ttype last_token;
static tree last_token_id; static tree last_token_id;
/* From lex.c: */ /* From lex.c: */
/* the declaration found for the last IDENTIFIER token read in. /* the declaration found for the last IDENTIFIER token read in. yylex
yylex must look this up to detect typedefs, which get token type TYPENAME, must look this up to detect typedefs, which get token type
so it is left around in case the identifier is not a typedef but is tTYPENAME, so it is left around in case the identifier is not a
used in a context which makes it a reference to a variable. */ typedef but is used in a context which makes it a reference to a
variable. */
extern tree lastiddecl; /* let our brains leak out here too */ extern tree lastiddecl; /* let our brains leak out here too */
extern int yychar; /* the lookahead symbol */ extern int yychar; /* the lookahead symbol */
extern YYSTYPE yylval; /* the semantic value of the */ extern YYSTYPE yylval; /* the semantic value of the */
...@@ -636,11 +637,11 @@ identifier_type (decl) ...@@ -636,11 +637,11 @@ identifier_type (decl)
if (t && t == decl) if (t && t == decl)
return SELFNAME; return SELFNAME;
return TYPENAME; return tTYPENAME;
} }
/* token[0] == AGGR (struct/union/enum) /* token[0] == AGGR (struct/union/enum)
Thus, token[1] is either a TYPENAME or a TYPENAME_DEFN. Thus, token[1] is either a tTYPENAME or a TYPENAME_DEFN.
If token[2] == '{' or ':' then it's TYPENAME_DEFN. If token[2] == '{' or ':' then it's TYPENAME_DEFN.
It's also a definition if it's a forward declaration (as in 'struct Foo;') It's also a definition if it's a forward declaration (as in 'struct Foo;')
which we can tell if token[2] == ';' *and* token[-1] != FRIEND or NEW. */ which we can tell if token[2] == ';' *and* token[-1] != FRIEND or NEW. */
...@@ -652,7 +653,7 @@ do_aggr () ...@@ -652,7 +653,7 @@ do_aggr ()
scan_tokens (2); scan_tokens (2);
yc1 = nth_token (1)->yychar; yc1 = nth_token (1)->yychar;
if (yc1 != TYPENAME && yc1 != IDENTIFIER && yc1 != PTYPENAME) if (yc1 != tTYPENAME && yc1 != IDENTIFIER && yc1 != PTYPENAME)
return; return;
yc2 = nth_token (2)->yychar; yc2 = nth_token (2)->yychar;
if (yc2 == ';') if (yc2 == ';')
...@@ -667,7 +668,7 @@ do_aggr () ...@@ -667,7 +668,7 @@ do_aggr ()
switch (yc1) switch (yc1)
{ {
case TYPENAME: case tTYPENAME:
nth_token (1)->yychar = TYPENAME_DEFN; nth_token (1)->yychar = TYPENAME_DEFN;
break; break;
case PTYPENAME: case PTYPENAME:
...@@ -765,7 +766,7 @@ yylex () ...@@ -765,7 +766,7 @@ yylex ()
break; break;
} }
case IDENTIFIER_DEFN: case IDENTIFIER_DEFN:
case TYPENAME: case tTYPENAME:
case TYPENAME_DEFN: case TYPENAME_DEFN:
case PTYPENAME: case PTYPENAME:
case PTYPENAME_DEFN: case PTYPENAME_DEFN:
...@@ -898,7 +899,7 @@ frob_id (yyc, peek, idp) ...@@ -898,7 +899,7 @@ frob_id (yyc, peek, idp)
yyc = identifier_type (trrr); yyc = identifier_type (trrr);
switch(yyc) switch(yyc)
{ {
case TYPENAME: case tTYPENAME:
case SELFNAME: case SELFNAME:
case NSNAME: case NSNAME:
case PTYPENAME: case PTYPENAME:
...@@ -1469,7 +1470,7 @@ debug_yychar (yy) ...@@ -1469,7 +1470,7 @@ debug_yychar (yy)
{ {
if (yy<256) if (yy<256)
fprintf (stderr, "->%d < %c >\n", lineno, yy); fprintf (stderr, "->%d < %c >\n", lineno, yy);
else if (yy == IDENTIFIER || yy == TYPENAME) else if (yy == IDENTIFIER || yy == tTYPENAME)
{ {
const char *id; const char *id;
if (TREE_CODE (yylval.ttype) == IDENTIFIER_NODE) if (TREE_CODE (yylval.ttype) == IDENTIFIER_NODE)
......
...@@ -73,6 +73,7 @@ typedef_struct: ENT_TYPEDEF_STRUCT options '{' struct_fields '}' ID ...@@ -73,6 +73,7 @@ typedef_struct: ENT_TYPEDEF_STRUCT options '{' struct_fields '}' ID
lexer_toplevel_done = 1; lexer_toplevel_done = 1;
} }
';' ';'
{}
| ENT_STRUCT options '{' struct_fields '}' | ENT_STRUCT options '{' struct_fields '}'
{ {
new_structure ($1->u.s.tag, UNION_P ($1), &lexer_line, new_structure ($1->u.s.tag, UNION_P ($1), &lexer_line,
...@@ -80,6 +81,7 @@ typedef_struct: ENT_TYPEDEF_STRUCT options '{' struct_fields '}' ID ...@@ -80,6 +81,7 @@ typedef_struct: ENT_TYPEDEF_STRUCT options '{' struct_fields '}' ID
lexer_toplevel_done = 1; lexer_toplevel_done = 1;
} }
';' ';'
{}
; ;
externstatic: ENT_EXTERNSTATIC options lasttype ID semiequal externstatic: ENT_EXTERNSTATIC options lasttype ID semiequal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment