X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=blobdiff_plain;f=gcc%2Fc-parse.in;h=86880ac61537121eebc6a685360f0a38edb290c0;hp=87dfc1007487f51ff15fd7b387cb346fb77bfc9b;hb=fe1549ae846f703581b3126d52794f84de00e61d;hpb=5cbd179d875444116e92838078534bcf689ccff3 diff --git a/gcc/c-parse.in b/gcc/c-parse.in index 87dfc100748..86880ac6153 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -52,7 +52,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "ggc.h" #include "c-common.h" -/* Like YYERROR but do call yyerror. */ #define YYERROR1 { yyerror ("syntax error"); YYERROR; } /* Like the default stack expander, except (1) use realloc when possible, @@ -102,8 +101,8 @@ do { \ %union {long itype; tree ttype; void *otype; struct c_expr exprtype; struct c_arg_info *arginfotype; struct c_declarator *dtrtype; struct c_type_name *typenametype; struct c_parm *parmtype; - struct c_declspecs *dsptype; enum tree_code code; - location_t location; } + struct c_declspecs *dsptype; struct c_typespec tstype; + enum tree_code code; location_t location; } /* All identifiers that are not reserved words and are not declared typedefs in the current block */ @@ -149,7 +148,6 @@ do { \ %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF %token ATTRIBUTE EXTENSION LABEL %token REALPART IMAGPART VA_ARG CHOOSE_EXPR TYPES_COMPATIBLE_P -%token PTR_VALUE PTR_BASE PTR_EXTENT %token FUNC_NAME OFFSETOF /* Add precedence rules to solve dangling else s/r conflict */ @@ -180,7 +178,7 @@ do { \ Objective C, so that the token codes are the same in both. */ %token AT_INTERFACE AT_IMPLEMENTATION AT_END AT_SELECTOR AT_DEFS AT_ENCODE %token CLASSNAME AT_PUBLIC AT_PRIVATE AT_PROTECTED AT_PROTOCOL -%token OBJECTNAME AT_CLASS AT_ALIAS +%token AT_CLASS AT_ALIAS %token AT_THROW AT_TRY AT_CATCH AT_FINALLY AT_SYNCHRONIZED %token OBJC_STRING @@ -203,9 +201,9 @@ do { \ %type declspecs_ts_nosa declspecs_nots_nosa %type declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs %type maybe_type_quals_attrs -%type typespec_nonattr typespec_attr -%type typespec_reserved_nonattr typespec_reserved_attr -%type typespec_nonreserved_nonattr +%type typespec_nonattr typespec_attr +%type typespec_reserved_nonattr typespec_reserved_attr +%type typespec_nonreserved_nonattr %type offsetof_member_designator %type scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_volatile @@ -227,7 +225,7 @@ do { \ %type parm_declarator_starttypename parm_declarator_nostarttypename %type array_declarator -%type structsp_attr structsp_nonattr +%type structsp_attr structsp_nonattr %type component_decl_list component_decl_list2 %type component_decl components components_notype component_declarator %type component_notype_declarator @@ -261,7 +259,7 @@ do { \ %type selectorarg keywordnamelist keywordname objcencodeexpr %type non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr -%type CLASSNAME OBJECTNAME OBJC_STRING OBJC_TYPE_QUAL +%type CLASSNAME OBJC_STRING OBJC_TYPE_QUAL %type superclass objc_quals objc_qual objc_typename %type objc_try_catch_stmt optellipsis @@ -386,7 +384,7 @@ extdefs: save_obstack_position { $$ = NULL; } extdef { obstack_free (&parser_obstack, $1); } | extdefs save_obstack_position - { $$ = NULL; ggc_collect(); } extdef + { $$ = NULL; ggc_collect (); } extdef { obstack_free (&parser_obstack, $2); } ; @@ -409,11 +407,7 @@ save_obstack_position: datadef: setspecs notype_initdecls ';' - { if (pedantic) - error ("ISO C forbids data definition with no type or storage class"); - else - warning ("data definition has no type or storage class"); - + { pedwarn ("data definition has no type or storage class"); POP_DECLSPEC_STACK; } | declspecs_nots setspecs notype_initdecls ';' { POP_DECLSPEC_STACK; } @@ -430,8 +424,8 @@ datadef: fndef: declspecs_ts setspecs declarator - { if (! start_function (current_declspecs, $3, - all_prefix_attributes)) + { if (!start_function (current_declspecs, $3, + all_prefix_attributes)) YYERROR1; } old_style_parm_decls save_location @@ -443,8 +437,8 @@ fndef: | declspecs_ts setspecs declarator error { POP_DECLSPEC_STACK; } | declspecs_nots setspecs notype_declarator - { if (! start_function (current_declspecs, $3, - all_prefix_attributes)) + { if (!start_function (current_declspecs, $3, + all_prefix_attributes)) YYERROR1; } old_style_parm_decls save_location @@ -456,8 +450,8 @@ fndef: | declspecs_nots setspecs notype_declarator error { POP_DECLSPEC_STACK; } | setspecs notype_declarator - { if (! start_function (current_declspecs, $2, - all_prefix_attributes)) + { if (!start_function (current_declspecs, $2, + all_prefix_attributes)) YYERROR1; } old_style_parm_decls save_location @@ -474,7 +468,6 @@ identifier: IDENTIFIER | TYPENAME @@ifobjc - | OBJECTNAME | CLASSNAME @@end_ifobjc ; @@ -690,7 +683,7 @@ primary: finish_init (); maybe_warn_string_init (type, init); - if (pedantic && ! flag_isoc99) + if (pedantic && !flag_isoc99) pedwarn ("ISO C90 forbids compound literals"); $$.value = build_compound_literal (type, constructor); $$.original_code = ERROR_MARK; @@ -740,7 +733,7 @@ primary: c = fold ($3.value); STRIP_NOPS (c); if (TREE_CODE (c) != INTEGER_CST) - error ("first argument to __builtin_choose_expr not" + error ("first argument to %<__builtin_choose_expr%> not" " a constant"); $$ = integer_zerop (c) ? $7 : $5; } @@ -1263,7 +1256,9 @@ typespec_attr: typespec_reserved_nonattr: TYPESPEC - { OBJC_NEED_RAW_IDENTIFIER (1); } + { OBJC_NEED_RAW_IDENTIFIER (1); + $$.kind = ctsk_resword; + $$.spec = $1; } | structsp_nonattr ; @@ -1275,17 +1270,21 @@ typespec_nonreserved_nonattr: TYPENAME { /* For a typedef name, record the meaning, not the name. In case of `foo foo, bar;'. */ - $$ = lookup_name ($1); } + $$.kind = ctsk_typedef; + $$.spec = lookup_name ($1); } @@ifobjc | CLASSNAME protocolrefs - { $$ = objc_get_protocol_qualified_type ($1, $2); } - | OBJECTNAME protocolrefs - { $$ = objc_get_protocol_qualified_type ($1, $2); } + { $$.kind = ctsk_objc; + $$.spec = objc_get_protocol_qualified_type ($1, $2); } + | TYPENAME non_empty_protocolrefs + { $$.kind = ctsk_objc; + $$.spec = objc_get_protocol_qualified_type ($1, $2); } /* Make "" equivalent to "id " - nisse@lysator.liu.se */ | non_empty_protocolrefs - { $$ = objc_get_protocol_qualified_type (NULL_TREE, $1); } + { $$.kind = ctsk_objc; + $$.spec = objc_get_protocol_qualified_type (NULL_TREE, $1); } @@end_ifobjc | typeof '(' expr ')' { skip_evaluation--; @@ -1293,11 +1292,17 @@ typespec_nonreserved_nonattr: if (TREE_CODE ($3.value) == COMPONENT_REF && DECL_C_BIT_FIELD (TREE_OPERAND ($3.value, 1))) error ("% applied to a bit-field"); - $$ = TREE_TYPE ($3.value); - pop_maybe_used (variably_modified_type_p ($$, NULL_TREE)); } + $$.kind = ctsk_typeof; + $$.spec = TREE_TYPE ($3.value); + pop_maybe_used (variably_modified_type_p ($$.spec, + NULL_TREE)); } | typeof '(' typename ')' - { skip_evaluation--; in_typeof--; $$ = groktypename ($3); - pop_maybe_used (variably_modified_type_p ($$, NULL_TREE)); } + { skip_evaluation--; + in_typeof--; + $$.kind = ctsk_typeof; + $$.spec = groktypename ($3); + pop_maybe_used (variably_modified_type_p ($$.spec, + NULL_TREE)); } ; /* typespec_nonreserved_attr does not exist. */ @@ -1433,9 +1438,9 @@ initlist1: It may use braces. */ initelt: designator_list '=' initval - { if (pedantic && ! flag_isoc99) + { if (pedantic && !flag_isoc99) pedwarn ("ISO C90 forbids specifying subobject to initialize"); } - | designator initval + | array_designator initval { if (pedantic) pedwarn ("obsolete use of designated initializer without %<=%>"); } | identifier ':' @@ -1465,7 +1470,11 @@ designator_list: designator: '.' identifier { set_init_label ($2); } - | '[' expr_no_commas ELLIPSIS expr_no_commas ']' + | array_designator + ; + +array_designator: + '[' expr_no_commas ELLIPSIS expr_no_commas ']' { set_init_index ($2.value, $4.value); if (pedantic) pedwarn ("ISO C forbids specifying range of elements to initialize"); } @@ -1479,8 +1488,8 @@ nested_function: pedwarn ("ISO C forbids nested functions"); push_function_context (); - if (! start_function (current_declspecs, $1, - all_prefix_attributes)) + if (!start_function (current_declspecs, $1, + all_prefix_attributes)) { pop_function_context (); YYERROR1; @@ -1509,8 +1518,8 @@ notype_nested_function: pedwarn ("ISO C forbids nested functions"); push_function_context (); - if (! start_function (current_declspecs, $1, - all_prefix_attributes)) + if (!start_function (current_declspecs, $1, + all_prefix_attributes)) { pop_function_context (); YYERROR1; @@ -1554,10 +1563,6 @@ after_type_declarator: { $$ = make_pointer_declarator ($2, $3); } | TYPENAME { $$ = build_id_declarator ($1); } -@@ifobjc - | OBJECTNAME - { $$ = build_id_declarator ($1); } -@@end_ifobjc ; /* Kinds of declarator that can appear in a parameter list @@ -1576,10 +1581,6 @@ parm_declarator_starttypename: { $$ = set_array_declarator_inner ($2, $1, false); } | TYPENAME { $$ = build_id_declarator ($1); } -@@ifobjc - | OBJECTNAME - { $$ = build_id_declarator ($1); } -@@end_ifobjc ; parm_declarator_nostarttypename: @@ -1640,47 +1641,55 @@ enum_head: structsp_attr: struct_head identifier '{' - { $$ = start_struct (RECORD_TYPE, $2); + { $$ = start_struct (RECORD_TYPE, $2); /* Start scope of tag before parsing components. */ } component_decl_list '}' maybe_attribute - { $$ = finish_struct ($4, nreverse ($5), - chainon ($1, $7)); } + { $$.spec = finish_struct ($4, nreverse ($5), + chainon ($1, $7)); + $$.kind = ctsk_tagdef; } | struct_head '{' component_decl_list '}' maybe_attribute - { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE), - nreverse ($3), chainon ($1, $5)); + { $$.spec = finish_struct (start_struct (RECORD_TYPE, + NULL_TREE), + nreverse ($3), chainon ($1, $5)); + $$.kind = ctsk_tagdef; } | union_head identifier '{' - { $$ = start_struct (UNION_TYPE, $2); } + { $$ = start_struct (UNION_TYPE, $2); } component_decl_list '}' maybe_attribute - { $$ = finish_struct ($4, nreverse ($5), - chainon ($1, $7)); } + { $$.spec = finish_struct ($4, nreverse ($5), + chainon ($1, $7)); + $$.kind = ctsk_tagdef; } | union_head '{' component_decl_list '}' maybe_attribute - { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE), - nreverse ($3), chainon ($1, $5)); + { $$.spec = finish_struct (start_struct (UNION_TYPE, + NULL_TREE), + nreverse ($3), chainon ($1, $5)); + $$.kind = ctsk_tagdef; } | enum_head identifier '{' - { $$ = start_enum ($2); } + { $$ = start_enum ($2); } enumlist maybecomma_warn '}' maybe_attribute - { $$ = finish_enum ($4, nreverse ($5), - chainon ($1, $8)); } + { $$.spec = finish_enum ($4, nreverse ($5), + chainon ($1, $8)); + $$.kind = ctsk_tagdef; } | enum_head '{' - { $$ = start_enum (NULL_TREE); } + { $$ = start_enum (NULL_TREE); } enumlist maybecomma_warn '}' maybe_attribute - { $$ = finish_enum ($3, nreverse ($4), - chainon ($1, $7)); } + { $$.spec = finish_enum ($3, nreverse ($4), + chainon ($1, $7)); + $$.kind = ctsk_tagdef; } ; structsp_nonattr: struct_head identifier - { $$ = xref_tag (RECORD_TYPE, $2); } + { $$ = parser_xref_tag (RECORD_TYPE, $2); } | union_head identifier - { $$ = xref_tag (UNION_TYPE, $2); } + { $$ = parser_xref_tag (UNION_TYPE, $2); } | enum_head identifier - { $$ = xref_tag (ENUMERAL_TYPE, $2); + { $$ = parser_xref_tag (ENUMERAL_TYPE, $2); /* In ISO C, enumerated types can be referred to only if already defined. */ - if (pedantic && !COMPLETE_TYPE_P ($$)) + if (pedantic && !COMPLETE_TYPE_P ($$.spec)) pedwarn ("ISO C forbids forward references to % types"); } ; @@ -1692,7 +1701,7 @@ maybecomma: maybecomma_warn: /* empty */ | ',' - { if (pedantic && ! flag_isoc99) + { if (pedantic && !flag_isoc99) pedwarn ("comma at end of enumerator list"); } ; @@ -1739,9 +1748,6 @@ component_decl: /* Support for unnamed structs or unions as members of structs or unions (which is [a] useful and [b] supports MS P-SDK). */ - if (pedantic) - pedwarn ("ISO C doesn't support unnamed structs/unions"); - $$ = grokfield (build_id_declarator (NULL_TREE), current_declspecs, NULL_TREE); POP_DECLSPEC_STACK; } @@ -2017,7 +2023,7 @@ compstmt_contents_nonempty: compstmt_primary_start: '(' '{' - { if (current_function_decl == 0) + { if (cur_stmt_list == NULL) { error ("braced-group within expression allowed " "only inside a function"); @@ -2568,7 +2574,7 @@ identifiers_or_typenames: extension: EXTENSION - { $$ = SAVE_EXT_FLAGS(); + { $$ = SAVE_EXT_FLAGS (); pedantic = 0; warn_pointer_arith = 0; warn_traditional = 0; @@ -2866,7 +2872,6 @@ selector: IDENTIFIER | TYPENAME | CLASSNAME - | OBJECTNAME | reservedwords ; @@ -2874,7 +2879,7 @@ reservedwords: ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF - | TYPESPEC | TYPE_QUAL + | TYPESPEC | TYPE_QUAL | OBJC_TYPE_QUAL ; objc_qual: @@ -3077,12 +3082,6 @@ static const struct resword reswords[] = { "__inline", RID_INLINE, 0 }, { "__inline__", RID_INLINE, 0 }, { "__label__", RID_LABEL, 0 }, - { "__ptrbase", RID_PTRBASE, 0 }, - { "__ptrbase__", RID_PTRBASE, 0 }, - { "__ptrextent", RID_PTREXTENT, 0 }, - { "__ptrextent__", RID_PTREXTENT, 0 }, - { "__ptrvalue", RID_PTRVALUE, 0 }, - { "__ptrvalue__", RID_PTRVALUE, 0 }, { "__real", RID_REALPART, 0 }, { "__real__", RID_REALPART, 0 }, { "__restrict", RID_RESTRICT, 0 }, @@ -3132,7 +3131,6 @@ static const struct resword reswords[] = { "while", RID_WHILE, 0 }, @@ifobjc - { "id", RID_ID, D_OBJC }, /* These objc keywords are recognized only immediately after an '@'. */ @@ -3236,9 +3234,6 @@ static const short rid_to_yy[RID_MAX] = /* RID_IMAGPART */ IMAGPART, /* RID_REALPART */ REALPART, /* RID_LABEL */ LABEL, - /* RID_PTRBASE */ PTR_BASE, - /* RID_PTREXTENT */ PTR_EXTENT, - /* RID_PTRVALUE */ PTR_VALUE, /* RID_CHOOSE_EXPR */ CHOOSE_EXPR, /* RID_TYPES_COMPATIBLE_P */ TYPES_COMPATIBLE_P, @@ -3278,7 +3273,6 @@ static const short rid_to_yy[RID_MAX] = /* RID_STATCAST */ 0, /* Objective C */ - /* RID_ID */ OBJECTNAME, /* RID_AT_ENCODE */ AT_ENCODE, /* RID_AT_END */ AT_END, /* RID_AT_CLASS */ AT_CLASS, @@ -3347,15 +3341,6 @@ yylexname (void) enum rid rid_code = C_RID_CODE (yylval.ttype); @@ifobjc - /* Turn non-typedefed refs to "id" into plain identifiers; this - allows constructs like "void foo(id id);" to work. */ - if (rid_code == RID_ID) - { - decl = lookup_name (yylval.ttype); - if (decl == NULL_TREE || TREE_CODE (decl) != TYPE_DECL) - return IDENTIFIER; - } - if (!OBJC_IS_AT_KEYWORD (rid_code) && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context)) @@end_ifobjc @@ -3518,7 +3503,6 @@ yyprint (FILE *file, int yychar, YYSTYPE yyl) { case IDENTIFIER: case TYPENAME: - case OBJECTNAME: case TYPESPEC: case TYPE_QUAL: case SCSPEC: @@ -3556,4 +3540,21 @@ c_parse_file (void) } } +#ifdef __XGETTEXT__ +/* Depending on the version of Bison used to compile this grammar, + it may issue generic diagnostics spelled "syntax error" or + "parse error". To prevent this from changing the translation + template randomly, we list all the variants of this particular + diagnostic here. Translators: there is no fine distinction + between diagnostics with "syntax error" in them, and diagnostics + with "parse error" in them. It's okay to give them both the same + translation. */ +const char d1[] = N_("syntax error"); +const char d2[] = N_("parse error"); +const char d3[] = N_("syntax error; also virtual memory exhausted"); +const char d4[] = N_("parse error; also virtual memory exhausted"); +const char d5[] = N_("syntax error: cannot back up"); +const char d6[] = N_("parse error: cannot back up"); +#endif + #include "gt-c-parse.h"