OSDN Git Service

* cse.c (cse_reg_info_free_list, cse_reg_info_used_list,
[pf3gnuchains/gcc-fork.git] / gcc / c-parse.in
index 7f6f4f4..fe0d517 100644 (file)
@@ -1,6 +1,6 @@
 /* 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, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+   1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -178,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
 
@@ -209,7 +209,7 @@ do {                                                                        \
 %type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_volatile
 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
 %type <exprtype> init
-%type <ttype> simple_asm_expr maybeasm asm_stmt asm_argument
+%type <ttype> simple_asm_expr maybeasm asm_stmt asm_argument asm_string
 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
 %type <ttype> any_word
@@ -259,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
@@ -407,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; }
@@ -472,7 +468,6 @@ identifier:
        IDENTIFIER
        | TYPENAME
 @@ifobjc
-       | OBJECTNAME
        | CLASSNAME
 @@end_ifobjc
        ;
@@ -738,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;
                }
@@ -1281,7 +1276,7 @@ typespec_nonreserved_nonattr:
        | CLASSNAME protocolrefs
                { $$.kind = ctsk_objc;
                  $$.spec = objc_get_protocol_qualified_type ($1, $2); }
-       | OBJECTNAME protocolrefs
+       | TYPENAME non_empty_protocolrefs
                { $$.kind = ctsk_objc;
                  $$.spec = objc_get_protocol_qualified_type ($1, $2); }
 
@@ -1326,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);
                 }
        ;
 
@@ -1343,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. */
@@ -1476,6 +1485,7 @@ designator:
          '.' identifier
                { set_init_label ($2); }
        | array_designator
+       ;
 
 array_designator:
          '[' expr_no_commas ELLIPSIS expr_no_commas ']'
@@ -1567,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
@@ -1589,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:
@@ -2328,7 +2330,7 @@ label:      CASE expr_no_commas ':'
    expression with inputs and outputs does not make sense.  */
 simple_asm_expr:
        ASM_KEYWORD stop_string_translation
-             '(' STRING ')' start_string_translation
+             '(' asm_string ')' start_string_translation
                { $$ = $4; }
        ;
 
@@ -2357,16 +2359,16 @@ asm_stmt:
 
 asm_argument:
        /* no operands */
-       STRING
+       asm_string
                { $$ = build_asm_expr ($1, 0, 0, 0, true); }
        /* output operands */
-       | STRING ':' asm_operands
+       | asm_string ':' asm_operands
                { $$ = build_asm_expr ($1, $3, 0, 0, false); }
        /* output and input operands */
-       | STRING ':' asm_operands ':' asm_operands
+       | asm_string ':' asm_operands ':' asm_operands
                { $$ = build_asm_expr ($1, $3, $5, 0, false); }
        /* output and input operands and clobbers */
-       | STRING ':' asm_operands ':' asm_operands ':' asm_clobbers
+       | asm_string ':' asm_operands ':' asm_operands ':' asm_clobbers
                { $$ = build_asm_expr ($1, $3, $5, $7, false); }
        ;
 
@@ -2400,10 +2402,11 @@ nonnull_asm_operands:
        ;
 
 asm_operand:
-         STRING start_string_translation '(' expr ')' stop_string_translation
+         asm_string start_string_translation '(' expr ')'
+           stop_string_translation
                { $$ = build_tree_list (build_tree_list (NULL_TREE, $1),
                                        $4.value); }
-       | '[' identifier ']' STRING start_string_translation
+       | '[' identifier ']' asm_string start_string_translation
          '(' expr ')' stop_string_translation
                { $2 = build_string (IDENTIFIER_LENGTH ($2),
                                     IDENTIFIER_POINTER ($2));
@@ -2411,12 +2414,25 @@ asm_operand:
        ;
 
 asm_clobbers:
-         STRING
+         asm_string
                { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
-       | asm_clobbers ',' STRING
+       | asm_clobbers ',' asm_string
                { $$ = tree_cons (NULL_TREE, $3, $1); }
        ;
 
+/* Strings in 'asm' must be narrow strings.  */
+asm_string:
+         STRING
+               { if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE ($1)))
+                     != char_type_node)
+                   {
+                     error ("wide string literal in %<asm%>");
+                     $$ = build_string (1, "");
+                   }
+                 else
+                   $$ = $1; }
+       ;
+
 stop_string_translation:
         { c_lex_string_translate = 0; }
         ;
@@ -2884,7 +2900,6 @@ selector:
          IDENTIFIER
        | TYPENAME
        | CLASSNAME
-       | OBJECTNAME
        | reservedwords
        ;
 
@@ -3144,7 +3159,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 '@'.  */
@@ -3287,7 +3301,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,
@@ -3356,15 +3369,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
@@ -3527,7 +3531,6 @@ yyprint (FILE *file, int yychar, YYSTYPE yyl)
     {
     case IDENTIFIER:
     case TYPENAME:
-    case OBJECTNAME:
     case TYPESPEC:
     case TYPE_QUAL:
     case SCSPEC: