OSDN Git Service

* config/sparc/sparc.md (save_register_windowdi): Add missing mode.
[pf3gnuchains/gcc-fork.git] / gcc / c-parse.in
index e469677..94df4bb 100644 (file)
@@ -101,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 */
@@ -148,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 */
@@ -179,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
 
@@ -202,9 +201,9 @@ do {                                                                        \
 %type <dsptype> declspecs_ts_nosa declspecs_nots_nosa
 %type <dsptype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs
 %type <dsptype> maybe_type_quals_attrs
-%type <ttype> typespec_nonattr typespec_attr
-%type <ttype> typespec_reserved_nonattr typespec_reserved_attr
-%type <ttype> typespec_nonreserved_nonattr
+%type <tstype> typespec_nonattr typespec_attr
+%type <tstype> typespec_reserved_nonattr typespec_reserved_attr
+%type <tstype> typespec_nonreserved_nonattr
 %type <ttype> offsetof_member_designator
 
 %type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_volatile
@@ -226,7 +225,7 @@ do {                                                                        \
 %type <dtrtype> parm_declarator_starttypename parm_declarator_nostarttypename
 %type <dtrtype> array_declarator
 
-%type <ttype> structsp_attr structsp_nonattr
+%type <tstype> structsp_attr structsp_nonattr
 %type <ttype> component_decl_list component_decl_list2
 %type <ttype> component_decl components components_notype component_declarator
 %type <ttype> component_notype_declarator
@@ -260,7 +259,7 @@ do {                                                                        \
 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
 %type <ttype> non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
 
-%type <ttype> CLASSNAME OBJECTNAME OBJC_STRING OBJC_TYPE_QUAL
+%type <ttype> CLASSNAME OBJC_STRING OBJC_TYPE_QUAL
 
 %type <ttype> superclass objc_quals objc_qual objc_typename
 %type <itype> objc_try_catch_stmt optellipsis
@@ -408,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; }
@@ -473,7 +468,6 @@ identifier:
        IDENTIFIER
        | TYPENAME
 @@ifobjc
-       | OBJECTNAME
        | CLASSNAME
 @@end_ifobjc
        ;
@@ -739,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;
                }
@@ -1262,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
        ;
 
@@ -1274,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 "<SomeProtocol>" equivalent to "id <SomeProtocol>"
    - 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--;
@@ -1292,11 +1292,17 @@ typespec_nonreserved_nonattr:
                  if (TREE_CODE ($3.value) == COMPONENT_REF
                      && DECL_C_BIT_FIELD (TREE_OPERAND ($3.value, 1)))
                    error ("%<typeof%> 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.  */
@@ -1315,16 +1321,23 @@ initdcl:
          declarator maybeasm maybe_attribute '='
                { $<ttype>$ = start_decl ($1, current_declspecs, true,
                                          chainon ($3, all_prefix_attributes));
+                 if (!$<ttype>$)
+                   $<ttype>$ = error_mark_node;
                  start_init ($<ttype>$, $2, global_bindings_p ()); }
          init
 /* Note how the declaration of the variable is in effect while its init is parsed! */
                { finish_init ();
-                 maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
-                 finish_decl ($<ttype>5, $6.value, $2); }
+                 if ($<ttype>5 != error_mark_node)
+                   {
+                     maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
+                     finish_decl ($<ttype>5, $6.value, $2);
+                   }
+               }
        | declarator maybeasm maybe_attribute
                { tree d = start_decl ($1, current_declspecs, false,
                                       chainon ($3, all_prefix_attributes));
-                 finish_decl (d, NULL_TREE, $2);
+                 if (d)
+                   finish_decl (d, NULL_TREE, $2);
                 }
        ;
 
@@ -1332,16 +1345,23 @@ notype_initdcl:
          notype_declarator maybeasm maybe_attribute '='
                { $<ttype>$ = start_decl ($1, current_declspecs, true,
                                          chainon ($3, all_prefix_attributes));
+                 if (!$<ttype>$)
+                   $<ttype>$ = error_mark_node;
                  start_init ($<ttype>$, $2, global_bindings_p ()); }
          init
 /* Note how the declaration of the variable is in effect while its init is parsed! */
                { finish_init ();
-                 maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
-                 finish_decl ($<ttype>5, $6.value, $2); }
+                 if ($<ttype>5 != error_mark_node)
+                   {
+                     maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
+                     finish_decl ($<ttype>5, $6.value, $2);
+                   }
+               }
        | notype_declarator maybeasm maybe_attribute
                { tree d = start_decl ($1, current_declspecs, false,
                                       chainon ($3, all_prefix_attributes));
-                 finish_decl (d, NULL_TREE, $2); }
+                 if (d)
+                    finish_decl (d, NULL_TREE, $2); }
        ;
 /* the * rules are dummies to accept the Apollo extended syntax
    so that the header files compile. */
@@ -1434,7 +1454,7 @@ initelt:
          designator_list '=' initval
                { 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 ':'
@@ -1464,7 +1484,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"); }
@@ -1553,10 +1577,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
@@ -1575,10 +1595,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:
@@ -1639,47 +1655,55 @@ enum_head:
 
 structsp_attr:
          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
-               { $$ = finish_struct ($<ttype>4, nreverse ($5),
-                                     chainon ($1, $7)); }
+               { $$.spec = finish_struct ($<ttype>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); }
+               { $<ttype>$ = start_struct (UNION_TYPE, $2); }
          component_decl_list '}' maybe_attribute
-               { $$ = finish_struct ($<ttype>4, nreverse ($5),
-                                     chainon ($1, $7)); }
+               { $$.spec = finish_struct ($<ttype>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); }
+               { $<ttype>$ = start_enum ($2); }
          enumlist maybecomma_warn '}' maybe_attribute
-               { $$ = finish_enum ($<ttype>4, nreverse ($5),
-                                   chainon ($1, $8)); }
+               { $$.spec = finish_enum ($<ttype>4, nreverse ($5),
+                                        chainon ($1, $8));
+                 $$.kind = ctsk_tagdef; }
        | enum_head '{'
-               { $$ = start_enum (NULL_TREE); }
+               { $<ttype>$ = start_enum (NULL_TREE); }
          enumlist maybecomma_warn '}' maybe_attribute
-               { $$ = finish_enum ($<ttype>3, nreverse ($4),
-                                   chainon ($1, $7)); }
+               { $$.spec = finish_enum ($<ttype>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 %<enum%> types"); }
        ;
 
@@ -2013,7 +2037,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");
@@ -2862,7 +2886,6 @@ selector:
          IDENTIFIER
        | TYPENAME
        | CLASSNAME
-       | OBJECTNAME
        | reservedwords
        ;
 
@@ -2870,7 +2893,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:
@@ -3073,12 +3096,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 },
@@ -3128,7 +3145,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 '@'.  */
@@ -3232,9 +3248,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,
@@ -3274,7 +3287,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,
@@ -3343,15 +3355,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
@@ -3514,7 +3517,6 @@ yyprint (FILE *file, int yychar, YYSTYPE yyl)
     {
     case IDENTIFIER:
     case TYPENAME:
-    case OBJECTNAME:
     case TYPESPEC:
     case TYPE_QUAL:
     case SCSPEC: