diff options
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r-- | gcc/c-parse.in | 417 |
1 files changed, 199 insertions, 218 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in index 787167c155d..3d14d916b07 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -20,17 +20,17 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This file defines the grammar of C and that of Objective C. - ifobjc ... end ifobjc conditionals contain code for Objective C only. - ifc ... end ifc conditionals contain code for C only. + @@ifobjc ... @@end_ifobjc conditionals contain code for Objective C only. + @@ifc ... @@end_ifc conditionals contain code for C only. Sed commands in Makefile.in are used to convert this file into c-parse.y and into objc-parse.y. */ /* To whomever it may concern: I have heard that such a thing was once written by AT&T, but I have never seen it. */ -ifc +@@ifc %expect 10 /* shift/reduce conflicts, and no reduce/reduce conflicts. */ -end ifc +@@end_ifc %{ #include "config.h" @@ -50,9 +50,9 @@ end ifc #include "toplev.h" #include "ggc.h" -ifobjc +@@ifobjc #include "objc-act.h" -end ifobjc +@@end_ifobjc /* Like YYERROR but do call yyerror. */ #define YYERROR1 { yyerror ("syntax error"); YYERROR; } @@ -75,15 +75,13 @@ do { \ newsize = *(YYSSZ) *= 2; \ if (malloced_yyss) \ { \ - newss = (short *) \ - really_call_realloc (*(SS), newsize * sizeof (short)); \ - newvs = (YYSTYPE *) \ - really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \ + newss = really_call_realloc (*(SS), newsize * sizeof (short)); \ + newvs = really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \ } \ else \ { \ - newss = (short *) really_call_malloc (newsize * sizeof (short)); \ - newvs = (YYSTYPE *) really_call_malloc (newsize * sizeof (YYSTYPE)); \ + newss = really_call_malloc (newsize * sizeof (short)); \ + newvs = really_call_malloc (newsize * sizeof (YYSTYPE)); \ if (newss) \ memcpy (newss, *(SS), (SSSIZE)); \ if (newvs) \ @@ -177,6 +175,7 @@ do { \ Objective C, so that the token codes are the same in both. */ %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS +%token AT_THROW AT_TRY AT_CATCH AT_FINALLY AT_SYNCHRONIZED %token OBJC_STRING %type <code> unop @@ -235,7 +234,7 @@ do { \ %type <location> save_location -ifobjc +@@ifobjc /* the Objective-C nonterminals */ %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator @@ -247,7 +246,10 @@ ifobjc %type <ttype> non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr %type <ttype> CLASSNAME OBJECTNAME OBJC_STRING -end ifobjc + +%type <ttype> objc_try_stmt superclass +%type <itype> objc_try_catch_stmt objc_finally_block +@@end_ifobjc %{ /* Number of statements (loosely speaking) and compound statements @@ -308,7 +310,7 @@ static GTY(()) tree declspec_stack; flag_iso = (val >> 3) & 1; \ } while (0) -ifobjc +@@ifobjc /* Objective-C specific parser/lexer information */ static enum tree_code objc_inherit_code; @@ -320,11 +322,11 @@ static int objc_pq_context = 0, objc_public_flag = 0; exists. */ static int objc_need_raw_identifier; #define OBJC_NEED_RAW_IDENTIFIER(VAL) objc_need_raw_identifier = VAL -end ifobjc +@@end_ifobjc -ifc +@@ifc #define OBJC_NEED_RAW_IDENTIFIER(VAL) /* nothing */ -end ifc +@@end_ifc static bool parsing_iso_function_signature; @@ -352,20 +354,8 @@ c_parse_init (void) program: /* empty */ { if (pedantic) pedwarn ("ISO C forbids an empty source file"); - finish_file (); } | extdefs - { - /* In case there were missing closebraces, - get us back to the global binding level. */ - while (! global_bindings_p ()) - poplevel (0, 0, 0); - /* __FUNCTION__ is defined at file scope (""). This - call may not be necessary as my tests indicate it - still works without it. */ - finish_fname_decls (); - finish_file (); - } ; /* the reason for the strange actions in this rule @@ -385,9 +375,9 @@ extdef: extdef_1: fndef | datadef -ifobjc +@@ifobjc | objcdef -end ifobjc +@@end_ifobjc | ASM_KEYWORD '(' expr ')' ';' { STRIP_NOPS ($3); if ((TREE_CODE ($3) == ADDR_EXPR @@ -431,7 +421,7 @@ fndef: { DECL_SOURCE_LOCATION (current_function_decl) = $6; store_parm_decls (); } compstmt_or_error - { finish_function (0, 1); + { finish_function (); POP_DECLSPEC_STACK; } | declspecs_ts setspecs declarator error { POP_DECLSPEC_STACK; } @@ -444,7 +434,7 @@ fndef: { DECL_SOURCE_LOCATION (current_function_decl) = $6; store_parm_decls (); } compstmt_or_error - { finish_function (0, 1); + { finish_function (); POP_DECLSPEC_STACK; } | declspecs_nots setspecs notype_declarator error { POP_DECLSPEC_STACK; } @@ -457,7 +447,7 @@ fndef: { DECL_SOURCE_LOCATION (current_function_decl) = $5; store_parm_decls (); } compstmt_or_error - { finish_function (0, 1); + { finish_function (); POP_DECLSPEC_STACK; } | setspecs notype_declarator error { POP_DECLSPEC_STACK; } @@ -466,10 +456,10 @@ fndef: identifier: IDENTIFIER | TYPENAME -ifobjc +@@ifobjc | OBJECTNAME | CLASSNAME -end ifobjc +@@end_ifobjc ; unop: '&' @@ -478,10 +468,10 @@ unop: '&' { $$ = NEGATE_EXPR; } | '+' { $$ = CONVERT_EXPR; -ifc +@@ifc if (warn_traditional && !in_system_header) warning ("traditional C rejects the unary plus operator"); -end ifc +@@end_ifc } | PLUSPLUS { $$ = PREINCREMENT_EXPR; } @@ -592,26 +582,26 @@ expr_no_commas: | expr_no_commas ANDAND { $1 = c_common_truthvalue_conversion (default_conversion ($1)); - skip_evaluation += $1 == boolean_false_node; } + skip_evaluation += $1 == truthvalue_false_node; } expr_no_commas - { skip_evaluation -= $1 == boolean_false_node; + { skip_evaluation -= $1 == truthvalue_false_node; $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); } | expr_no_commas OROR { $1 = c_common_truthvalue_conversion (default_conversion ($1)); - skip_evaluation += $1 == boolean_true_node; } + skip_evaluation += $1 == truthvalue_true_node; } expr_no_commas - { skip_evaluation -= $1 == boolean_true_node; + { skip_evaluation -= $1 == truthvalue_true_node; $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); } | expr_no_commas '?' { $1 = c_common_truthvalue_conversion (default_conversion ($1)); - skip_evaluation += $1 == boolean_false_node; } + skip_evaluation += $1 == truthvalue_false_node; } expr ':' - { skip_evaluation += (($1 == boolean_true_node) - - ($1 == boolean_false_node)); } + { skip_evaluation += (($1 == truthvalue_true_node) + - ($1 == truthvalue_false_node)); } expr_no_commas - { skip_evaluation -= $1 == boolean_true_node; + { skip_evaluation -= $1 == truthvalue_true_node; $$ = build_conditional_expr ($1, $4, $7); } | expr_no_commas '?' { if (pedantic) @@ -620,9 +610,9 @@ expr_no_commas: $<ttype>2 = save_expr ($1); $1 = c_common_truthvalue_conversion (default_conversion ($<ttype>2)); - skip_evaluation += $1 == boolean_true_node; } + skip_evaluation += $1 == truthvalue_true_node; } ':' expr_no_commas - { skip_evaluation -= $1 == boolean_true_node; + { skip_evaluation -= $1 == truthvalue_true_node; $$ = build_conditional_expr ($1, $<ttype>2, $5); } | expr_no_commas '=' expr_no_commas { char class; @@ -678,8 +668,6 @@ primary: if (pedantic) pedwarn ("ISO C forbids braced-groups within expressions"); - pop_label_level (); - saved_last_tree = COMPOUND_BODY ($1); RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); last_tree = saved_last_tree; @@ -691,7 +679,6 @@ primary: } | compstmt_primary_start error ')' { - pop_label_level (); last_tree = COMPOUND_BODY ($1); TREE_CHAIN (last_tree) = NULL_TREE; $$ = error_mark_node; @@ -718,36 +705,36 @@ primary: e1 = TYPE_MAIN_VARIANT (groktypename ($3)); e2 = TYPE_MAIN_VARIANT (groktypename ($5)); - $$ = comptypes (e1, e2) + $$ = comptypes (e1, e2, COMPARE_STRICT) ? build_int_2 (1, 0) : build_int_2 (0, 0); } | primary '[' expr ']' %prec '.' { $$ = build_array_ref ($1, $3); } | primary '.' identifier { -ifobjc +@@ifobjc if (!is_public ($1, $3)) $$ = error_mark_node; else -end ifobjc +@@end_ifobjc $$ = build_component_ref ($1, $3); } | primary POINTSAT identifier { tree expr = build_indirect_ref ($1, "->"); -ifobjc +@@ifobjc if (!is_public (expr, $3)) $$ = error_mark_node; else -end ifobjc +@@end_ifobjc $$ = build_component_ref (expr, $3); } | primary PLUSPLUS { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); } | primary MINUSMINUS { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); } -ifobjc +@@ifobjc | objcmessageexpr { $$ = build_message_expr ($1); } | objcselectorexpr @@ -758,7 +745,7 @@ ifobjc { $$ = build_encode_expr ($1); } | OBJC_STRING { $$ = build_objc_string_object ($1); } -end ifobjc +@@end_ifobjc ; old_style_parm_decls: @@ -774,9 +761,16 @@ old_style_parm_decls_1: if (warn_traditional && !in_system_header && parsing_iso_function_signature) warning ("traditional C rejects ISO C style function definitions"); + if (warn_old_style_definition && !in_system_header + && !parsing_iso_function_signature) + warning ("old-style parameter declaration"); parsing_iso_function_signature = false; /* Reset after warning. */ } | datadecls + { + if (warn_old_style_definition && !in_system_header) + warning ("old-style parameter declaration"); + } ; /* The following are analogous to lineno_decl, decls and decl @@ -1366,7 +1360,7 @@ typespec_nonreserved_nonattr: { /* For a typedef name, record the meaning, not the name. In case of `foo foo, bar;'. */ $$ = lookup_name ($1); } -ifobjc +@@ifobjc | CLASSNAME protocolrefs { $$ = get_static_reference ($1, $2); } | OBJECTNAME protocolrefs @@ -1376,7 +1370,7 @@ ifobjc - nisse@lysator.liu.se */ | non_empty_protocolrefs { $$ = get_object_reference ($1); } -end ifobjc +@@end_ifobjc | typeof '(' expr ')' { skip_evaluation--; $$ = TREE_TYPE ($3); } | typeof '(' typename ')' @@ -1583,7 +1577,7 @@ nested_function: which called YYERROR1 again, and so on. */ compstmt { tree decl = current_function_decl; - finish_function (1, 1); + finish_function (); pop_function_context (); add_decl_stmt (decl); } ; @@ -1614,7 +1608,7 @@ notype_nested_function: which called YYERROR1 again, and so on. */ compstmt { tree decl = current_function_decl; - finish_function (1, 1); + finish_function (); pop_function_context (); add_decl_stmt (decl); } ; @@ -1642,9 +1636,9 @@ after_type_declarator: | '*' maybe_type_quals_attrs after_type_declarator %prec UNARY { $$ = make_pointer_declarator ($2, $3); } | TYPENAME -ifobjc +@@ifobjc | OBJECTNAME -end ifobjc +@@end_ifobjc ; /* Kinds of declarator that can appear in a parameter list @@ -1665,9 +1659,9 @@ parm_declarator_starttypename: | parm_declarator_starttypename array_declarator %prec '.' { $$ = set_array_declarator_type ($2, $1, 0); } | TYPENAME -ifobjc +@@ifobjc | OBJECTNAME -end ifobjc +@@end_ifobjc ; parm_declarator_nostarttypename: @@ -1816,22 +1810,11 @@ component_decl_list2: /* empty */ | component_decl_list2 ';' { if (pedantic) pedwarn ("extra semicolon in struct or union specified"); } -ifobjc +@@ifobjc /* foo(sizeof(struct{ @defs(ClassName)})); */ | DEFS '(' CLASSNAME ')' - { - tree interface = lookup_interface ($3); - - if (interface) - $$ = nreverse (get_class_ivars (interface)); - else - { - error ("cannot find interface declaration for `%s'", - IDENTIFIER_POINTER ($3)); - $$ = NULL_TREE; - } - } -end ifobjc + { $$ = nreverse (get_class_ivars_from_name ($3)); } +@@end_ifobjc ; component_decl: @@ -1854,7 +1837,7 @@ component_decl: | declspecs_nosc_nots { if (pedantic) pedwarn ("ISO C forbids member declarations with no members"); - shadow_tag($1); + shadow_tag_warned ($1, pedantic); $$ = NULL_TREE; } | error { $$ = NULL_TREE; } @@ -2030,8 +2013,11 @@ lineno_stmt_decl_or_labels_ending_stmt: lineno_stmt_decl_or_labels_ending_decl: lineno_decl | lineno_stmt_decl_or_labels_ending_stmt lineno_decl - { if (pedantic && !flag_isoc99) - pedwarn ("ISO C89 forbids mixed declarations and code"); } + { + if ((pedantic && !flag_isoc99) + || warn_declaration_after_statement) + pedwarn_c90 ("ISO C90 forbids mixed declarations and code"); + } | lineno_stmt_decl_or_labels_ending_decl lineno_decl | lineno_stmt_decl_or_labels_ending_error lineno_decl ; @@ -2063,15 +2049,17 @@ pushlevel: /* empty */ { pushlevel (0); clear_last_expr (); add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0); -ifobjc - if (objc_method_context) - add_objc_decls (); -end ifobjc } ; poplevel: /* empty */ - { $$ = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0); } + { +@@ifobjc + if (c_dialect_objc ()) + objc_clear_super_receiver (); +@@end_ifobjc + $$ = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0); + } ; /* Start and end blocks created for the new scopes of C99. */ @@ -2082,10 +2070,6 @@ c99_block_start: /* empty */ pushlevel (0); clear_last_expr (); add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0); -ifobjc - if (objc_method_context) - add_objc_decls (); -end ifobjc } else $$ = NULL_TREE; @@ -2099,7 +2083,7 @@ c99_block_end: /* empty */ { if (flag_isoc99) { tree scope_stmt = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0); - $$ = poplevel (kept_level_p (), 0, 0); + $$ = poplevel (KEEP_MAYBE, 0, 0); SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmt)) = SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmt)) = $$; @@ -2127,7 +2111,7 @@ label_decl: { tree link; for (link = $2; link; link = TREE_CHAIN (link)) { - tree label = shadow_label (TREE_VALUE (link)); + tree label = declare_label (TREE_VALUE (link)); C_DECLARED_LABEL_FLAG (label) = 1; add_decl_stmt (label); } @@ -2149,7 +2133,7 @@ compstmt_start: '{' { compstmt_count++; compstmt_nostart: '}' { $$ = convert (void_type_node, integer_zero_node); } | pushlevel maybe_label_decls compstmt_contents_nonempty '}' poplevel - { $$ = poplevel (kept_level_p (), 1, 0); + { $$ = poplevel (KEEP_MAYBE, 0, 0); SCOPE_STMT_BLOCK (TREE_PURPOSE ($5)) = SCOPE_STMT_BLOCK (TREE_VALUE ($5)) = $$; } @@ -2172,7 +2156,6 @@ compstmt_primary_start: there is a way to turn off the entire subtree of blocks that are contained in it. */ keep_next_level (); - push_label_level (); compstmt_count++; $$ = add_stmt (build_stmt (COMPOUND_STMT, last_tree)); } @@ -2412,6 +2395,59 @@ stmt: $$ = add_stmt (build_stmt (GOTO_STMT, $3)); } | ';' { $$ = NULL_TREE; } +@@ifobjc + | AT_THROW expr ';' + { stmt_count++; + $$ = objc_build_throw_stmt ($2); + } + | AT_THROW ';' + { stmt_count++; + $$ = objc_build_throw_stmt (NULL_TREE); + } + | objc_try_catch_stmt + { objc_build_finally_prologue (); } + objc_finally_block + { $$ = objc_build_try_catch_finally_stmt ($1, $3); } + | AT_SYNCHRONIZED '(' expr ')' + { objc_build_synchronized_prologue ($3); } + compstmt + { $$ = objc_build_synchronized_epilogue (); } + ; + +objc_try_catch_stmt: + objc_try_stmt + { objc_build_try_epilogue (1); } + objc_catch_list + { objc_build_catch_epilogue (); $$ = 1; } + | objc_try_stmt + { objc_build_try_epilogue (0); $$ = 0; } + ; + + +objc_try_stmt: + AT_TRY + { objc_build_try_prologue (); } + compstmt + ; + +objc_catch_list: + objc_catch_list objc_catch_block + | objc_catch_block + ; + +objc_catch_block: + AT_CATCH '(' parm ')' + { objc_build_catch_stmt ($3); } + compstmt + { stmt_count++; } + ; + +objc_finally_block: + AT_FINALLY compstmt + { $$ = 1; } + | /* NULL */ + { $$ = 0; } +@@end_ifobjc ; /* Any kind of label, including jump labels and case labels. @@ -2493,24 +2529,16 @@ asm_clobbers: parmlist: maybe_attribute { pushlevel (0); - clear_parm_order (); - declare_parm_level (0); } + declare_parm_level (); } parmlist_1 { $$ = $3; - parmlist_tags_warning (); poplevel (0, 0, 0); } ; parmlist_1: parmlist_2 ')' | parms ';' - { tree parm; - if (pedantic) - pedwarn ("ISO C forbids forward parameter declarations"); - /* Mark the forward decls as such. */ - for (parm = getdecls (); parm; parm = TREE_CHAIN (parm)) - TREE_ASM_WRITTEN (parm) = 1; - clear_parm_order (); } + { mark_forward_parm_decls (); } maybe_attribute { /* Dummy action so attributes are in known place on parser stack. */ } @@ -2615,11 +2643,9 @@ setspecs_fp: parmlist_or_identifiers: maybe_attribute { pushlevel (0); - clear_parm_order (); - declare_parm_level (1); } + declare_parm_level (); } parmlist_or_identifiers_1 { $$ = $3; - parmlist_tags_warning (); poplevel (0, 0, 0); } ; @@ -2666,7 +2692,7 @@ extension: flag_iso = 0; } ; -ifobjc +@@ifobjc /* Objective-C productions. */ objcdef: @@ -2710,103 +2736,41 @@ aliasdecl: } ; -classdef: - INTERFACE identifier protocolrefs '{' - { - objc_interface_context = objc_ivar_context - = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3); - objc_public_flag = 0; - } - ivar_decl_list '}' - { - continue_class (objc_interface_context); - } - methodprotolist - END - { - finish_class (objc_interface_context); - objc_interface_context = NULL_TREE; - } +superclass: + ':' identifier { $$ = $2; } + | /* NULL */ %prec HYPERUNARY { $$ = NULL_TREE; } + ; - | INTERFACE identifier protocolrefs - { - objc_interface_context - = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3); - continue_class (objc_interface_context); - } - methodprotolist - END - { - finish_class (objc_interface_context); - objc_interface_context = NULL_TREE; - } +class_ivars: + '{' ivar_decl_list '}' + | /* NULL */ + ; - | INTERFACE identifier ':' identifier protocolrefs '{' +classdef: + INTERFACE identifier superclass protocolrefs { objc_interface_context = objc_ivar_context - = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5); + = start_class (CLASS_INTERFACE_TYPE, $2, $3, $4); objc_public_flag = 0; } - ivar_decl_list '}' - { - continue_class (objc_interface_context); - } - methodprotolist - END - { - finish_class (objc_interface_context); - objc_interface_context = NULL_TREE; - } - - | INTERFACE identifier ':' identifier protocolrefs + class_ivars { - objc_interface_context - = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5); continue_class (objc_interface_context); } - methodprotolist - END + methodprotolist END { finish_class (objc_interface_context); objc_interface_context = NULL_TREE; } - | IMPLEMENTATION identifier '{' - { - objc_implementation_context = objc_ivar_context - = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE); - objc_public_flag = 0; - } - ivar_decl_list '}' - { - objc_ivar_chain - = continue_class (objc_implementation_context); - } - - | IMPLEMENTATION identifier - { - objc_implementation_context - = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE); - objc_ivar_chain - = continue_class (objc_implementation_context); - } - - | IMPLEMENTATION identifier ':' identifier '{' + | IMPLEMENTATION identifier superclass { objc_implementation_context = objc_ivar_context - = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE); + = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $3, NULL_TREE); objc_public_flag = 0; } - ivar_decl_list '}' - { - objc_ivar_chain - = continue_class (objc_implementation_context); - } - - | IMPLEMENTATION identifier ':' identifier + class_ivars { - objc_implementation_context - = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE); objc_ivar_chain = continue_class (objc_implementation_context); } @@ -2817,8 +2781,7 @@ classdef: = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6); continue_class (objc_interface_context); } - methodprotolist - END + methodprotolist END { finish_class (objc_interface_context); objc_interface_context = NULL_TREE; @@ -2965,10 +2928,7 @@ methoddef: methoddecl { objc_pq_context = 0; - if (objc_inherit_code == CLASS_METHOD_DECL) - add_class_method (objc_implementation_context, $3); - else - add_instance_method (objc_implementation_context, $3); + add_method (objc_implementation_context, $3, objc_inherit_code == CLASS_METHOD_DECL); start_method_def ($3); } optarglist @@ -2987,14 +2947,8 @@ methoddef: methodprotolist: /* empty */ - | {$<ttype>$ = NULL_TREE; } methodprotolist2 - ; - -methodprotolist2: /* eliminates a shift/reduce conflict */ - methodproto - | datadef - | methodprotolist2 methodproto - | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef + | methodprotolist methodproto + | methodprotolist { $<ttype>$ = NULL_TREE; } datadef ; semi_or_error: @@ -3012,10 +2966,7 @@ methodproto: { /* Forget protocol qualifiers here. */ objc_pq_context = 0; - if (objc_inherit_code == CLASS_METHOD_DECL) - add_class_method (objc_interface_context, $3); - else - add_instance_method (objc_interface_context, $3); + add_method (objc_interface_context, $3, objc_inherit_code == CLASS_METHOD_DECL); } semi_or_error ; @@ -3212,6 +3163,10 @@ receiver: { $$ = get_class_reference ($1); } + | TYPENAME + { + $$ = get_class_reference ($1); + } ; objcmessageexpr: @@ -3266,7 +3221,7 @@ objcencodeexpr: } ; -end ifobjc +@@end_ifobjc %% /* yylex() is a thin wrapper around c_lex(), all it does is translate @@ -3368,7 +3323,7 @@ static const struct resword reswords[] = { "void", RID_VOID, 0 }, { "volatile", RID_VOLATILE, 0 }, { "while", RID_WHILE, 0 }, -ifobjc +@@ifobjc { "id", RID_ID, D_OBJC }, /* These objc keywords are recognized only immediately after @@ -3385,7 +3340,11 @@ ifobjc { "protocol", RID_AT_PROTOCOL, D_OBJC }, { "public", RID_AT_PUBLIC, D_OBJC }, { "selector", RID_AT_SELECTOR, D_OBJC }, - + { "throw", RID_AT_THROW, D_OBJC }, + { "try", RID_AT_TRY, D_OBJC }, + { "catch", RID_AT_CATCH, D_OBJC }, + { "finally", RID_AT_FINALLY, D_OBJC }, + { "synchronized", RID_AT_SYNCHRONIZED, D_OBJC }, /* These are recognized only in protocol-qualifier context (see above) */ { "bycopy", RID_BYCOPY, D_OBJC }, @@ -3394,7 +3353,7 @@ ifobjc { "inout", RID_INOUT, D_OBJC }, { "oneway", RID_ONEWAY, D_OBJC }, { "out", RID_OUT, D_OBJC }, -end ifobjc +@@end_ifobjc }; #define N_reswords (sizeof reswords / sizeof (struct resword)) @@ -3521,6 +3480,11 @@ static const short rid_to_yy[RID_MAX] = /* RID_AT_PUBLIC */ PUBLIC, /* RID_AT_PROTOCOL */ PROTOCOL, /* RID_AT_SELECTOR */ SELECTOR, + /* RID_AT_THROW */ AT_THROW, + /* RID_AT_TRY */ AT_TRY, + /* RID_AT_CATCH */ AT_CATCH, + /* RID_AT_FINALLY */ AT_FINALLY, + /* RID_AT_SYNCHRONIZED */ AT_SYNCHRONIZED, /* RID_AT_INTERFACE */ INTERFACE, /* RID_AT_IMPLEMENTATION */ IMPLEMENTATION }; @@ -3536,7 +3500,7 @@ init_reswords (void) if (!c_dialect_objc ()) mask |= D_OBJC; - ridpointers = (tree *) ggc_calloc ((int) RID_MAX, sizeof (tree)); + ridpointers = ggc_calloc ((int) RID_MAX, sizeof (tree)); for (i = 0; i < N_reswords; i++) { /* If a keyword is disabled, do not enter it into the table @@ -3585,16 +3549,16 @@ yylexname (void) { tree decl; -ifobjc +@@ifobjc int objc_force_identifier = objc_need_raw_identifier; OBJC_NEED_RAW_IDENTIFIER (0); -end ifobjc +@@end_ifobjc if (C_IS_RESERVED_WORD (yylval.ttype)) { enum rid rid_code = C_RID_CODE (yylval.ttype); -ifobjc +@@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) @@ -3606,7 +3570,7 @@ ifobjc if (!OBJC_IS_AT_KEYWORD (rid_code) && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context)) -end ifobjc +@@end_ifobjc { /* Return the canonical spelling for this keyword. */ yylval.ttype = ridpointers[(int) rid_code]; @@ -3620,7 +3584,7 @@ end ifobjc if (TREE_CODE (decl) == TYPE_DECL) return TYPENAME; } -ifobjc +@@ifobjc else { tree objc_interface_decl = is_class_name (yylval.ttype); @@ -3634,7 +3598,7 @@ ifobjc return CLASSNAME; } } -end ifobjc +@@end_ifobjc return IDENTIFIER; } @@ -3795,10 +3759,27 @@ yyprint (FILE *file, int yychar, YYSTYPE yyl) void free_parser_stacks (void) { +} + +/* Parse the file. */ +void +c_parse_file (void) +{ + yyparse (); + /* In case there were missing closebraces, get us back to the global + binding level. */ + while (! global_bindings_p ()) + poplevel (0, 0, 0); + /* __FUNCTION__ is defined at file scope (""). This + call may not be necessary as my tests indicate it + still works without it. */ + finish_fname_decls (); + if (malloced_yyss) { free (malloced_yyss); free (malloced_yyvs); + malloced_yyss = 0; } } |