/* 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.
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
%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
%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
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; }
IDENTIFIER
| TYPENAME
@@ifobjc
- | OBJECTNAME
| CLASSNAME
@@end_ifobjc
;
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;
}
| 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); }
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);
}
;
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. */
'.' identifier
{ set_init_label ($2); }
| array_designator
+ ;
array_designator:
'[' expr_no_commas ELLIPSIS expr_no_commas ']'
{ $$ = 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
{ $$ = set_array_declarator_inner ($2, $1, false); }
| TYPENAME
{ $$ = build_id_declarator ($1); }
-@@ifobjc
- | OBJECTNAME
- { $$ = build_id_declarator ($1); }
-@@end_ifobjc
;
parm_declarator_nostarttypename:
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; }
;
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); }
;
;
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));
;
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; }
;
IDENTIFIER
| TYPENAME
| CLASSNAME
- | OBJECTNAME
| reservedwords
;
{ "while", RID_WHILE, 0 },
@@ifobjc
- { "id", RID_ID, D_OBJC },
/* These objc keywords are recognized only immediately after
an '@'. */
/* RID_STATCAST */ 0,
/* Objective C */
- /* RID_ID */ OBJECTNAME,
/* RID_AT_ENCODE */ AT_ENCODE,
/* RID_AT_END */ AT_END,
/* RID_AT_CLASS */ AT_CLASS,
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
{
case IDENTIFIER:
case TYPENAME:
- case OBJECTNAME:
case TYPESPEC:
case TYPE_QUAL:
case SCSPEC: