Skip to content

Commit

Permalink
Fixing a couple of midrules to work with recent versions of Bison
Browse files Browse the repository at this point in the history
The errors were similar to:
c-parse.y:1743.19-20: $$ for the midrule at $4 of `structsp_attr' has no
declared type

Versions of Bison prior to 2.3 didn't detect this error correctly:
https://lists.gnu.org/archive/html/help-bison/2009-03/msg00015.html
  • Loading branch information
Steve Little committed Aug 30, 2018
1 parent db4beec commit 7480169
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions gcc-2.95.3/gcc/c-parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ char *language_string = "GNU C";

/* Cause the `yydebug' variable to be defined. */
#define YYDEBUG 1

#ifndef YYLEX
#define YYLEX yylex()
#endif
%}

%start program
Expand Down Expand Up @@ -1321,7 +1325,7 @@ enum_head:

structsp:
struct_head identifier '{'
{ $$ = start_struct (RECORD_TYPE, $2);
{ $<ttype>$ = start_struct (RECORD_TYPE, $2);
/* Start scope of tag before parsing components. */
}
component_decl_list '}' maybe_attribute
Expand All @@ -1333,7 +1337,7 @@ structsp:
| struct_head identifier
{ $$ = xref_tag (RECORD_TYPE, $2); }
| union_head identifier '{'
{ $$ = start_struct (UNION_TYPE, $2); }
{ $<ttype>$ = start_struct (UNION_TYPE, $2); }
component_decl_list '}' maybe_attribute
{ $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
| union_head '{' component_decl_list '}' maybe_attribute
Expand All @@ -1344,13 +1348,13 @@ structsp:
{ $$ = xref_tag (UNION_TYPE, $2); }
| enum_head identifier '{'
{ $<itype>3 = suspend_momentary ();
$$ = start_enum ($2); }
$<ttype>$ = start_enum ($2); }
enumlist maybecomma_warn '}' maybe_attribute
{ $$= finish_enum ($<ttype>4, nreverse ($5), chainon ($1, $8));
resume_momentary ($<itype>3); }
| enum_head '{'
{ $<itype>2 = suspend_momentary ();
$$ = start_enum (NULL_TREE); }
$<ttype>$ = start_enum (NULL_TREE); }
enumlist maybecomma_warn '}' maybe_attribute
{ $$= finish_enum ($<ttype>3, nreverse ($4), chainon ($1, $7));
resume_momentary ($<itype>2); }
Expand Down
12 changes: 8 additions & 4 deletions gcc-2.95.3/gcc/cp/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ extern int end_of_file;
/* Like YYERROR but do call yyerror. */
#define YYERROR1 { yyerror ("syntax error"); YYERROR; }

#ifndef YYLEX
#define YYLEX yylex
#endif

#define OP0(NODE) (TREE_OPERAND (NODE, 0))
#define OP1(NODE) (TREE_OPERAND (NODE, 1))

Expand Down Expand Up @@ -653,31 +657,31 @@ fndef:

constructor_declarator:
nested_name_specifier SELFNAME '('
{ $$ = begin_constructor_declarator ($1, $2); }
{ $<ttype>$ = begin_constructor_declarator ($1, $2); }
parmlist ')' cv_qualifiers exception_specification_opt
{ $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
| nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
{ $$ = begin_constructor_declarator ($1, $2);
$$ = make_call_declarator ($$, empty_parms (), $4, $5);
}
| global_scope nested_name_specifier SELFNAME '('
{ $$ = begin_constructor_declarator ($2, $3); }
{ $<ttype>$ = begin_constructor_declarator ($2, $3); }
parmlist ')' cv_qualifiers exception_specification_opt
{ $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
| global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
{ $$ = begin_constructor_declarator ($2, $3);
$$ = make_call_declarator ($$, empty_parms (), $5, $6);
}
| nested_name_specifier self_template_type '('
{ $$ = begin_constructor_declarator ($1, $2); }
{ $<ttype>$ = begin_constructor_declarator ($1, $2); }
parmlist ')' cv_qualifiers exception_specification_opt
{ $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
| nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
{ $$ = begin_constructor_declarator ($1, $2);
$$ = make_call_declarator ($$, empty_parms (), $4, $5);
}
| global_scope nested_name_specifier self_template_type '('
{ $$ = begin_constructor_declarator ($2, $3); }
{ $<ttype>$ = begin_constructor_declarator ($2, $3); }
parmlist ')' cv_qualifiers exception_specification_opt
{ $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
| global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
Expand Down

0 comments on commit 7480169

Please sign in to comment.