diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-12 03:25:38 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-12 03:25:38 +0000 |
commit | 4d2aa485d66d731a3726186c5be15f869b5895f9 (patch) | |
tree | d64fee370dcba52f3ebdc46db60f749bc198bad5 /gcc/c-parse.in | |
parent | 26398ccb63dde50f8039ed075b55280a2521f4d3 (diff) | |
download | gcc-4d2aa485d66d731a3726186c5be15f869b5895f9.tar.gz |
PR c/10675
* c-decl.c: Include hashtab.h.
(detect_field_duplicates): New.
(finish_struct): Use it.
* Makefile.in (c-decl.o): Update.
* c-parse.in (structsp_attr): Nreverse component_decl_list results.
(component_decl_list, component_decl_list2,
components, components_notype): Build list in reverse order.
(enumlist): Clarify docs. Use TREE_CHAIN not chainon.
* tree.c (chainon): Special case op2 null as well.
Reorg for clarity.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66710 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r-- | gcc/c-parse.in | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in index f9d3656662d..a9400b39d8f 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -1,4 +1,4 @@ - /* YACC parser for C syntax and for Objective C. -*-c-*- +/* YACC parser for C syntax and for Objective C. -*-c-*- Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. @@ -1759,18 +1759,20 @@ structsp_attr: /* Start scope of tag before parsing components. */ } component_decl_list '}' maybe_attribute - { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); } + { $$ = finish_struct ($<ttype>4, nreverse ($5), + chainon ($1, $7)); } | struct_head '{' component_decl_list '}' maybe_attribute { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE), - $3, chainon ($1, $5)); + nreverse ($3), chainon ($1, $5)); } | union_head identifier '{' { $$ = start_struct (UNION_TYPE, $2); } component_decl_list '}' maybe_attribute - { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); } + { $$ = finish_struct ($<ttype>4, nreverse ($5), + chainon ($1, $7)); } | union_head '{' component_decl_list '}' maybe_attribute { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE), - $3, chainon ($1, $5)); + nreverse ($3), chainon ($1, $5)); } | enum_head identifier '{' { $$ = start_enum ($2); } @@ -1809,18 +1811,30 @@ maybecomma_warn: pedwarn ("comma at end of enumerator list"); } ; +/* We chain the components in reverse order. They are put in forward + order in structsp_attr. + + Note that component_declarator returns single decls, so components + and components_notype can use TREE_CHAIN directly, wheras components + and components_notype return lists (of comma separated decls), so + component_decl_list and component_decl_list2 must use chainon. + + The theory behind all this is that there will be more semicolon + separated fields than comma separated fields, and so we'll be + minimizing the number of node traversals required by chainon. */ + component_decl_list: component_decl_list2 { $$ = $1; } | component_decl_list2 component_decl - { $$ = chainon ($1, $2); + { $$ = chainon ($2, $1); pedwarn ("no semicolon at end of struct or union"); } ; component_decl_list2: /* empty */ { $$ = NULL_TREE; } | component_decl_list2 component_decl ';' - { $$ = chainon ($1, $2); } + { $$ = chainon ($2, $1); } | component_decl_list2 ';' { if (pedantic) pedwarn ("extra semicolon in struct or union specified"); } @@ -1831,7 +1845,7 @@ ifobjc tree interface = lookup_interface ($3); if (interface) - $$ = get_class_ivars (interface); + $$ = nreverse (get_class_ivars (interface)); else { error ("cannot find interface declaration for `%s'", @@ -1874,13 +1888,13 @@ component_decl: components: component_declarator | components ',' maybe_resetattrs component_declarator - { $$ = chainon ($1, $4); } + { TREE_CHAIN ($4) = $1; $$ = $4; } ; components_notype: component_notype_declarator | components_notype ',' maybe_resetattrs component_notype_declarator - { $$ = chainon ($1, $4); } + { TREE_CHAIN ($4) = $1; $$ = $4; } ; component_declarator: @@ -1910,9 +1924,7 @@ component_notype_declarator: ; /* We chain the enumerators in reverse order. - They are put in forward order where enumlist is used. - (The order used to be significant, but no longer is so. - However, we still maintain the order, just to be clean.) */ + They are put in forward order in structsp_attr. */ enumlist: enumerator @@ -1920,7 +1932,7 @@ enumlist: { if ($1 == error_mark_node) $$ = $1; else - $$ = chainon ($3, $1); } + TREE_CHAIN ($3) = $1, $$ = $3; } | error { $$ = error_mark_node; } ; |