aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-parse.in
diff options
context:
space:
mode:
authorZiemowit Laski <zlaski@apple.com>2004-09-08 00:49:44 +0000
committerZiemowit Laski <zlaski@gcc.gnu.org>2004-09-08 00:49:44 +0000
commit6408ef338629d26c64ed03cee951bc2e4e2bfddc (patch)
tree39e252e037a2e91d03654547f193dfc01d41993a /gcc/c-parse.in
parent8662eb14c0ef6531d7086ec08f5e52b87c472ede (diff)
downloadgcc-6408ef338629d26c64ed03cee951bc2e4e2bfddc.zip
gcc-6408ef338629d26c64ed03cee951bc2e4e2bfddc.tar.gz
gcc-6408ef338629d26c64ed03cee951bc2e4e2bfddc.tar.bz2
Makefile.in (c-parse.o): Depend on $(C_COMMON_H).
[gcc/ChangeLog] 2004-09-07 Ziemowit Laski <zlaski@apple.com> * Makefile.in (c-parse.o): Depend on $(C_COMMON_H). * c-parse.in: Include c-common.h instead of objc-act.h. (ivar_decl_list, ivar_decls, ivar_decl, ivars, ivar_declarator, myparms, myparm): Remove %type declarations. (methodtype, optparms, OBJC_TYPE_QUAL, objc_quals, objc_qual, objc_typename, objc_try_catch_stmt, optellipsis): Add %type declarations. (objc_inherit_code, objc_public_flag): Remove. (typespec_nonreserved_nonattr): Call objc_get_protocol_qualified_type() instead of get_static_reference() and get_protocol_reference(). (stmt_nocomp): Call grokparm() on @catch parameter. (objcdef): Move semantic action to objc_finish_implementation(). (classdef): Move semantic action to objc_start_class_interface(), objc_continue_interface(), objc_finish_interface(), objc_start_class_implementation(), objc_continue_implementation(), objc_start_category_interface() and objc_start_category_implementation(). (protocoldef): Move semantic actions to objc_start_protocol() and objc_finish_interface(). (ivar_decl_list): Remove nonterminal. (visibility_spec): Move semantic actions to objc_set_visibility(). (ivar_decls): Remove assignment to $$. (ivar_decl): Rephrase in terms of component_decl; call objc_add_instance_variable(). (ivars, ivar_declarator): Remove nonterminals. (opt_semi): New nonterminal. (methodtype): Remove semantic actions. (methoddef): Move semantic actions to objc_set_method_type(), objc_start_method_definition() and objc_finish_method_definition(). (methodproto): Move semantic actions to objc_set_method_type() and objc_add_method_declaration(). (methoddecl): Use objc_typename instead of typename; move semantic actions to objc_build_method_signature(). (optarglist, myxdecls, mydecl, myparms, myparm): Remove nonterminals. (optparmlist): Express in terms of optparms and optellipsis. (optparms, optellipsis, objc_qual, objc_quals, objc_typename): New nonterminals. (keyworddecl): Use objc_typename instead of typename. (rid_to_yy): Mark RID_IN, RID_OUT, RID_INOUT, RID_BYCOPY, RID_BYREF and RID_ONEWAY as returning OBJC_TYPE_QUAL to yyparse(). [gcc/objc/ChangeLog] 2004-09-07 Ziemowit Laski <zlaski@apple.com> * Make-lang.in (objc/objc-parse.o): Depend on $(C_COMMON_H) instead of objc/objc-act.h. (objc/objc-act.o): Depend on $(HASHTAB_H). * objc-act.c: Include hashtab.h; in ObjC++ mode, include cp-tree.h and objcp-decl.h instead of c-tree.h. (build_module_descriptor, get_class_ivars, synth_id_with_class_suffix, error_with_ivar, gen_method_decl, gen_declaration, setup_string_decl, build_protocol_template): Adjust prototypes. (build_module_initializer_routine, start_class, continue_class, finish_class, start_method_def, objc_start_function, start_protocol, build_method_decl, objc_add_method, add_instance_variable, build_ivar_reference, is_ivar, is_private, get_super_receiver, build_selector_table_decl, objc_push_parm, objc_get_parm_info, gen_type_name, gen_type_name_0, start_var_decl, finish_var_decl, create_field_decl): New prototypes. (objc_expand_function_end, comp_method_with_proto, objc_expr_last, gen_declaration_1, gen_declarator, is_complex_decl, adorn_decl, define_decl, create_builtin_decl, gen_declspecs): Remove prototypes. (TYPE_ID): Rename to OBJECT_TYPEDEF_NAME. (CLASS_TYPEDEF_NAME): New. (TAG_EXECCLASS): Change from a global variable to a #define. (TAG_RETURN_STRUCT): Delete. (TAG_GNUINIT): New, holds '__objc_gnu_init' name. (objc_inherit_code, objc_public_flag): New, moved from c-parse.in. (string_descriptor): New struct. (string_htab): New hash table. (string_hash, string_eq): New prototypes. (generate_struct_by_value_array): Call create_field_decl() instead of create_builtin_decl(). (objc_init): Do not initialize objc_ellipsis_node or TAG_EXECCLASS; In ObjC++ mode, call cxx_init() instead of c_objc_common_init(). (objc_finish_file): In ObjC++, call instantiate_pending_templates() and cp_finish_file(). (define_decl, get_static_reference, get_protocol_reference, create_builtin_decl): Remove functions. (objc_start_class_interface, objc_start_category_interface, objc_start_protocol, objc_continue_interface, objc_finish_interface, objc_start_class_implementation, objc_start_category_implementation, objc_continue_implementation, objc_finish_implementation, objc_set_visibility, objc_set_method_type, objc_build_method_signature, objc_add_method_declaration, objc_start_method_definition, objc_add_instance_variable, objc_get_protocol_qualified_type, create_field_decl, start_var_decl, finish_var_decl): New functions. (setup_string_decl): Simplify since it is only called once. (synth_module_prologue): Call build_class_template(); predefine 'id' and 'Class' as typedefs; rename 'temp_type' to 'type'; disable debug hooks for duration of function; fix GNU runtime messenger signatures to correspond to reality; forward-declare '__objc_exec_class' for the GNU runtime; call build_selector_table_decl(); in ObjC++ mode, generate 'extern "C" { ... }' wrappers around synthesized declarations; call build_protocol_template() and build_category_template(). (string_hash, string_eq): New functions. (objc_build_string_object): Check metaclass correctness only once; store string literals in hash table. (objc_build_constructor): Do not convert initializer elements; adjust for ObjC++ impedance mismatch. (build_objc_symtab_template): Call create_field_decl() instead of create_builtin_decl(). (init_objc_symtab): Add missing conversion to initializer element. (build_metadata_decl): Call start_var_decl() instead of define_decl(). (generate_objc_symtab_decl): Do not call build_category_template(); call start_var_decl() and finish_var_decl() instead of start_decl() and finish_decl(). (build_module_descriptor): Call create_field_decl() instead of grokfield(); call start_var_decl() and finish_var_decl() instead of start_decl() and finish_decl(); always mark module descriptor as used; move GNU runtime-specific functionality to build_module_initializer_routine(). (build_module_initializer_routine): New function, broken off of build_module_descriptor(). (objc_static_init_needed_p, objc_generate_static_init_call): New functions. (generate_static_references, generate_strings, build_selector_translation_table, generate_descriptor_table, generate_ivars_list, generate_dispatch_table, generate_category): Call start_var_decl() and finish_var_decl() instead of start_decl() and finish_decl(); build a type directly instead of via groktypename(). (build_selector_reference_decl, build_selector_table_decl, build_class_reference_decl, build_protocol_reference, generate_objc_image_info): Call start_var_decl() instead of build_decl(). (build_selector_reference): For GNU runtime, do not call build_selector_reference_decl(). (build_selector, build_typed_selector_reference): Always convert result to the selector type. (add_objc_string): Cast return value to 'char *'. (build_method_prototype_template, build_selector_template, build_method_template): Use actual selector type for fields pointing to selectors. (finish_objc): For GNU runtime, call build_module_initializer_routine() after build_module_descriptor(). (generate_protocol_list, generate_shared_structures): Call start_var_decl() and finish_var_decl() instead of start_decl() and finish_decl(); build a type directly instead of via groktypename(). (synth_id_with_class_suffix): Return a string. (get_arg_type_list): For instance methods, use the instance type for 'self'; do not call groktypename_in_parm_context(). (build_objc_string_decl): Squash redeclaration errors in ObjC++. (objc_is_class_name): Use OBJC_TYPE_NAME instead of TYPE_NAME; handle RECORD_TYPEs in ObjC as well as ObjC++. (objc_is_id): New function. (objc_is_object_ptr): Return the canonical type node. (objc_get_class_ivars): Simplify using get_class_ivars(). (get_class_ivars): Remove second parameter; create a fresh copy of the ivar list for each call; do not check for existence of super class. (objc_eh_runtime_type): Mark #ifndef OBJCPLUS. (objc_init_exceptions): When using SJLJ-style exceptions, require the use of '-fobjc-exceptions' flag; do not require it for DWARF-style exceptions. (objc_build_exc_ptr, next_sjlj_build_try_catch_finally): Use objc_object_type instead of objc_id_type. (objc_begin_catch_clause): Convert the incoming PARM_DECL into a VAR_DECL before placing it in the appropriate scope; do not call define_decl(); adjust call to c_begin_compound_stmt(); use objc_object_type instead of objc_id_type. (build_next_objc_exception_stuff): Call create_field_decl() instead of create_builtin_decl(); construct type directly instead of calling groktypename(); use OBJC_VOID_AT_END to mark end of function parameters. (build_private_template): Adjust call to get_class_ivars(); build a type directly instead of via groktypename(). (build_protocol_template, build_method_prototype_list_template, build_method_prototype_template, build_category_template, build_selector_template, build_class_template, build_super_template, build_ivar_template, build_ivar_list_template, build_method_list_template, build_method_template): Call create_field_decl() instead of grokfield(). (objc_method_parm_type): Do not call groktypename(). (generate_descriptor_table): Call start_var_decl() and finish_var_decl() instead of start_decl() and finish_decl(). (generate_method_descriptors, build_protocol_initializer, generate_dispatch_tables, build_category_initializer, build_shared_structure_initializer): Do not call groktypename(). (generate_protocols): Call start_var_decl() and finish_var_decl() instead of start_decl() and finish_decl(); do not call groktypename(). (error_with_ivar): Remove last parameter. (check_ivars): Do not iterate ovar CLASS_RAW_IVARS lists in addition to CLASS_IVARS lists; adjust calls to error_with_ivar(). (generate_ivar_lists): Convert one of the initializer elements; do not call groktypename(). (get_arg_type_list, start_method_def, gen_method_def): Account for new representation of variable arguments and '...' in Objective-C methods; add Objective-C++ impedance matching code. (is_objc_type_qualifier): Remove function. (adjust_type_for_id_default): Simplify; there is no longer a need to wade through declspecs. (lookup_interface, start_class, continue_class, finish_class, start_method_def, start_protocol, build_method_decl, objc_add_method, add_instance_variable, build_ivar_reference, is_ivar, is_private, get_super_receiver, objc_build_finally_epilogue): Make into static functions. (receiver_is_class_object): Use new IS_CLASS() macro. (objc_build_message_expr): Tweak ObjC++ message argument handling; call objc_finish_message_expr() instead of finish_message_expr(). (finish_message_expr): Rename to objc_finish_message_expr(); use OBJC_TYPE_NAME and OBJC_SET_TYPE_NAME macros instead of TYPE_NAME. call gen_type_name() instead of gen_declaration(); call objc_is_id() instead of using IS_ID and IS_CLASS; Use objc_class_name instead of calling get_identifier("Class"); handle CONVERT_EXPRs in receiver. (build_objc_method_call, warn_with_method): Do not call groktypename(). (build_ivar_reference): Call convert() instead of clobbering in a type. (hash_init): Initialize string_htab hash table. (add_instance_variable): Simplify parameter list; do not call grokfield(); do not populate CLASS_IVARS list. (start_class): Check for the existence of super class, if one was specified. (continue_class): Use CLASS_RAW_IVARS rather than CLASS_IVARS; do not call build_class_template(); adjust call to get_class_ivars(); call build_decl(), pushdecl() and finish_decl() instead of define_decl(). (finish_class): Call build_decl(), pushdecl() and finish_decl() instead of define_decl(). (add_protocols): Use PROTOCOL_BINFO_ELTS for the tree vector size. (start_protocol): Do not call build_protocol_template(); use PROTOCOL_BINFO_ELTS for the tree vector size. (encode_type_qualifiers): Do not handle the 'const' qualifier here. (encode_pointer): Encode 'const char *' as 'r*', for backwards compatibility. (encode_array): Use HOST_WIDE_INT_PRINT_DEC instead of "%ld". (encode_type): Handle the 'const' qualifier here. (objc_parmlist): New global variable, sued by objc_push_parm and objc_get_parm_info(). (objc_push_parm, objc_get_parm_info): New functions. (objc_expr_last): Remove function. (synth_self_and_ucmd_args): For instance methods, use the instance type for 'self'; call objc_push_parm() instead of push_parm_decl(). (start_method_def): Do not call push_scope(), declare_parm_level(), pop_scope(), push_parm_decl(), store_parm_decls() or objc_expr_last(); just use objc_push_parm() and objc_get_parm_info(). (comp_method_with_proto): Remove function. (objc_types_are_equivalent): Strip away indirections before comparing underlying types. (comp_proto_with_proto): Do not call groktypename(); types are no longer in raw declspec format. (objc_start_function): New function. (really_start_method): Call comp_proto_with_proto() instead of comp_method_with_proto(); call objc_start_function() instead of hand-crafting a function declarator. (continue_method_def, objc_expand_function_end): Remove functions. (get_super_receiver): Call objc_get_current_scope() instead of get_current_scope(); reference 'super_class' field (instead of 'class'). (finish_method_def): Rename to objc_finish_method_definition() and add a function decl parameter; move method encoding call from objc_expand_function_end(). (is_complex_decl, adorn_decl, gen_declarator, gen_declspecs, gen_declaration_1): Remove functions. (tmpbuf, RAW_DECLSPEC): Remove. (gen_declaration): Remove second parameter; simplify to deal with TYPE_P nodes instead of raw declspecs. (gen_type_name, gen_type_name_0): New functions. (gen_method_decl): Remove second parameter; call gen_type_name() instead of gen_declaration_1(). (dump_interface): Adjust calls to gen_declaration() and gen_method_decl(); do not allocate a separate string buffer. (init_objc): Allocate a larger string buffer to accommodate dump_interface(); adjust call to build_module_descriptor(); add call to build_module_initializer_routine() for the GNU runtime. (generate_classref_translation_entry): Do not call start_decl(); call finish_var_decl() instead of finish_decl(); call convert() instead of build_c_cast(). * objc-act.h (CLASS_OWN_IVARS): Remove accessor. (CLASS_BINFO_ELTS): Reduce from 6 to 5, now that CLASS_OWN_IVARS is gone. (OCTI_GNU_INIT_DECL, GNU_INIT_decl): New. (OCTI_ELLIPSIS_NODE, objc_ellipsis_node): Remove. (OCTI_ID_ID, id_type, objc_id_id): Rename to OCTI_ID_NAME, objc_object_type and objc_object_name, respectively. (OCTI_CLS_REF, OCTI_CLASS_NAME, objc_class_reference, objc_class_name): New. (IS_CLASS): New macro. (IS_ID, IS_SUPER): Robustify. (OCTI_EXECCLASS_DECL, execclass_decl): New. (finish_file, start_class, continue_class, finish_class, start_method_def, continue_method_def, finish_method_def, start_protocol, finish_protocol, objc_build_throw_stmt, objc_build_try_catch_finally_stmt, objc_build_synchronized_prologue, objc_build_synchronized_epilogue, objc_build_try_prologue, objc_build_try_epilogue, objc_build_catch_stmt, objc_build_catch_epilogue, objc_build_finally_prologue, objc_build_finally_epilogue, is_ivar, is_private, is_public, add_instance_variable, objc_add_method, get_super_receiver, objc_clear_super_receiver, get_class_ivars_from_name, get_class_reference, get_static_reference, get_object_reference, build_message_expr, finish_message_expr, build_selector_expr, build_ivar_reference, build_keyword_decl, build_method_decl, build_protocol_expr, build_objc_string_object, objc_declare_alias, objc_declare_class, objc_declare_protocols, objc_comptypes, objc_check_decl, build_encode_expr): Remove prototypes. (imp_count, cat_count): Make GGC-aware. (OBJC_SET_TYPE_NAME): New macro. From-SVN: r87168
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r--gcc/c-parse.in311
1 files changed, 113 insertions, 198 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index d45ff5e..9774bcf 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -50,10 +50,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "output.h"
#include "toplev.h"
#include "ggc.h"
-
-@@ifobjc
-#include "objc-act.h"
-@@end_ifobjc
+#include "c-common.h"
/* Like YYERROR but do call yyerror. */
#define YYERROR1 { yyerror ("syntax error"); YYERROR; }
@@ -179,7 +176,7 @@ do { \
/* The Objective-C keywords. These are included in C and in
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 CLASSNAME AT_PUBLIC AT_PRIVATE AT_PROTECTED AT_PROTOCOL
%token OBJECTNAME AT_CLASS AT_ALIAS
%token AT_THROW AT_TRY AT_CATCH AT_FINALLY AT_SYNCHRONIZED
%token OBJC_STRING
@@ -248,17 +245,18 @@ do { \
@@ifobjc
/* the Objective-C nonterminals */
-%type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
%type <ttype> methoddecl unaryselector keywordselector selector
+%type <code> methodtype
%type <ttype> keyworddecl receiver objcmessageexpr messageargs
%type <ttype> keywordexpr keywordarglist keywordarg
-%type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
+%type <ttype> optparmlist optparms reservedwords objcselectorexpr
%type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
%type <ttype> non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
-%type <ttype> CLASSNAME OBJECTNAME OBJC_STRING
+%type <ttype> CLASSNAME OBJECTNAME OBJC_STRING OBJC_TYPE_QUAL
-%type <ttype> superclass
+%type <ttype> superclass objc_quals objc_qual objc_typename
+%type <itype> objc_try_catch_stmt optellipsis
@@end_ifobjc
%{
@@ -315,8 +313,7 @@ static tree offsetof_base;
@@ifobjc
/* Objective-C specific parser/lexer information */
-static enum tree_code objc_inherit_code;
-static int objc_pq_context = 0, objc_public_flag = 0;
+static int objc_pq_context = 0;
/* The following flag is needed to contextualize ObjC lexical analysis.
In some cases (e.g., 'int NSObject;'), it is undesirable to bind
@@ -1368,14 +1365,14 @@ typespec_nonreserved_nonattr:
$$ = lookup_name ($1); }
@@ifobjc
| CLASSNAME protocolrefs
- { $$ = get_static_reference ($1, $2); }
+ { $$ = objc_get_protocol_qualified_type ($1, $2); }
| OBJECTNAME protocolrefs
- { $$ = get_protocol_reference ($2); }
+ { $$ = objc_get_protocol_qualified_type ($1, $2); }
/* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
- nisse@lysator.liu.se */
| non_empty_protocolrefs
- { $$ = get_protocol_reference ($1); }
+ { $$ = objc_get_protocol_qualified_type (NULL_TREE, $1); }
@@end_ifobjc
| typeof '(' expr ')'
{ skip_evaluation--;
@@ -2315,7 +2312,7 @@ stmt_nocomp:
objc_catch_prefix:
AT_CATCH '(' parm ')'
- { objc_begin_catch_clause ($3); }
+ { objc_begin_catch_clause (grokparm ($3)); }
;
objc_catch_clause:
@@ -2645,14 +2642,7 @@ objcdef:
| methoddef
| AT_END
{
- if (objc_implementation_context)
- {
- finish_class (objc_implementation_context);
- objc_ivar_chain = NULL_TREE;
- objc_implementation_context = NULL_TREE;
- }
- else
- warning ("`@end' must appear in an implementation context");
+ objc_finish_implementation ();
}
;
@@ -2691,50 +2681,38 @@ class_ivars:
classdef:
AT_INTERFACE identifier superclass protocolrefs
{
- objc_interface_context = objc_ivar_context
- = start_class (CLASS_INTERFACE_TYPE, $2, $3, $4);
- objc_public_flag = 0;
+ objc_start_class_interface ($2, $3, $4);
}
class_ivars
{
- continue_class (objc_interface_context);
+ objc_continue_interface ();
}
methodprotolist AT_END
{
- finish_class (objc_interface_context);
- objc_interface_context = NULL_TREE;
+ objc_finish_interface ();
}
| AT_IMPLEMENTATION identifier superclass
{
- objc_implementation_context = objc_ivar_context
- = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $3, NULL_TREE);
- objc_public_flag = 0;
+ objc_start_class_implementation ($2, $3);
}
class_ivars
{
- objc_ivar_chain
- = continue_class (objc_implementation_context);
+ objc_continue_implementation ();
}
| AT_INTERFACE identifier '(' identifier ')' protocolrefs
{
- objc_interface_context
- = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
- continue_class (objc_interface_context);
+ objc_start_category_interface ($2, $4, $6);
}
methodprotolist AT_END
{
- finish_class (objc_interface_context);
- objc_interface_context = NULL_TREE;
+ objc_finish_interface ();
}
| AT_IMPLEMENTATION identifier '(' identifier ')'
{
- objc_implementation_context
- = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
- objc_ivar_chain
- = continue_class (objc_implementation_context);
+ objc_start_category_implementation ($2, $4);
}
;
@@ -2742,14 +2720,12 @@ protocoldef:
AT_PROTOCOL identifier protocolrefs
{
objc_pq_context = 1;
- objc_interface_context
- = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
+ objc_start_protocol ($2, $3);
}
methodprotolist AT_END
{
objc_pq_context = 0;
- finish_protocol(objc_interface_context);
- objc_interface_context = NULL_TREE;
+ objc_finish_interface ();
}
/* The @protocol forward-declaration production introduces a
reduce/reduce conflict on ';', which should be resolved in
@@ -2779,109 +2755,67 @@ non_empty_protocolrefs:
;
ivar_decl_list:
- ivar_decl_list visibility_spec ivar_decls
- | ivar_decls
+ /* empty */
+ | ivar_decl_list visibility_spec ivar_decls
;
visibility_spec:
- AT_PRIVATE { objc_public_flag = 2; }
- | AT_PROTECTED { objc_public_flag = 0; }
- | AT_PUBLIC { objc_public_flag = 1; }
+ /* empty */
+ | AT_PRIVATE { objc_set_visibility (2); }
+ | AT_PROTECTED { objc_set_visibility (0); }
+ | AT_PUBLIC { objc_set_visibility (1); }
;
ivar_decls:
- /* empty */
- {
- $$ = NULL_TREE;
- }
+ /* empty */
| ivar_decls ivar_decl ';'
| ivar_decls ';'
{
- if (pedantic)
+ if (pedantic)
pedwarn ("extra semicolon in struct or union specified");
- }
+ }
;
-
-/* There is a shift-reduce conflict here, because `components' may
- start with a `typename'. It happens that shifting (the default resolution)
- does the right thing, because it treats the `typename' as part of
- a `typed_typespecs'.
-
- It is possible that this same technique would allow the distinction
- between `notype_initdecls' and `initdecls' to be eliminated.
- But I am being cautious and not trying it. */
-
ivar_decl:
- declspecs_nosc_ts setspecs ivars
- { $$ = $3;
- POP_DECLSPEC_STACK; }
- | declspecs_nosc_nots setspecs ivars
- { $$ = $3;
- POP_DECLSPEC_STACK; }
- | error
- { $$ = NULL_TREE; }
- ;
+ component_decl
+ {
+ /* Comma-separated ivars are chained together in
+ reverse order; add them one by one. */
+ tree ivar = nreverse ($1);
-ivars:
- /* empty */
- { $$ = NULL_TREE; }
- | ivar_declarator
- | ivars ',' maybe_resetattrs ivar_declarator
+ for (; ivar; ivar = TREE_CHAIN (ivar))
+ objc_add_instance_variable (copy_node (ivar));
+ }
;
-ivar_declarator:
- declarator
- {
- $$ = add_instance_variable (objc_ivar_context,
- objc_public_flag,
- $1, current_declspecs,
- NULL_TREE);
- }
- | declarator ':' expr_no_commas
- {
- $$ = add_instance_variable (objc_ivar_context,
- objc_public_flag,
- $1, current_declspecs, $3.value);
- }
- | ':' expr_no_commas
+opt_semi:
+ /* NULL */
+ | ';'
{
- $$ = add_instance_variable (objc_ivar_context,
- objc_public_flag,
- NULL_TREE,
- current_declspecs, $2.value);
- }
+ if (pedantic)
+ pedwarn ("extra semicolon in method definition specified");
+ }
;
methodtype:
'+'
- { objc_inherit_code = CLASS_METHOD_DECL; }
| '-'
- { objc_inherit_code = INSTANCE_METHOD_DECL; }
;
methoddef:
methodtype
{
+ objc_set_method_type ($1);
objc_pq_context = 1;
- if (!objc_implementation_context)
- fatal_error ("method definition not in class context");
}
- methoddecl
+ methoddecl opt_semi
{
objc_pq_context = 0;
- objc_add_method (objc_implementation_context,
- $3,
- objc_inherit_code == CLASS_METHOD_DECL);
- start_method_def ($3);
- }
- optarglist
- {
- continue_method_def ();
+ objc_start_method_definition ($3);
}
compstmt_or_error
{
- finish_method_def ();
+ objc_finish_method_definition (current_function_decl);
}
;
@@ -2903,6 +2837,7 @@ semi_or_error:
methodproto:
methodtype
{
+ objc_set_method_type ($1);
/* Remember protocol qualifiers in prototypes. */
objc_pq_context = 1;
}
@@ -2910,109 +2845,63 @@ methodproto:
{
/* Forget protocol qualifiers here. */
objc_pq_context = 0;
- objc_add_method (objc_interface_context,
- $3,
- objc_inherit_code == CLASS_METHOD_DECL);
+ objc_add_method_declaration ($3);
}
semi_or_error
;
methoddecl:
- '(' typename ')' unaryselector
+ '(' objc_typename ')' unaryselector
{
- $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
+ $$ = objc_build_method_signature ($2, $4, NULL_TREE);
}
| unaryselector
{
- $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
+ $$ = objc_build_method_signature (NULL_TREE, $1, NULL_TREE);
}
- | '(' typename ')' keywordselector optparmlist
+ | '(' objc_typename ')' keywordselector optparmlist
{
- $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
+ $$ = objc_build_method_signature ($2, $4, $5);
}
| keywordselector optparmlist
{
- $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
+ $$ = objc_build_method_signature (NULL_TREE, $1, $2);
}
;
-/* "optarglist" assumes that start_method_def has already been called...
- if it is not, the "xdecls" will not be placed in the proper scope */
-
-optarglist:
- /* empty */
- | ';' myxdecls
- ;
-
-/* to get around the following situation: "int foo (int a) int b; {}" that
- is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
-
-myxdecls:
- /* empty */
- | mydecls
- ;
-
-mydecls:
- mydecl
- | errstmt
- | mydecls mydecl
- | mydecl errstmt
- ;
-
-mydecl:
- declspecs_ts setspecs myparms ';'
- { POP_DECLSPEC_STACK; }
- | declspecs_ts ';'
- { shadow_tag ($1); }
- | declspecs_nots ';'
- { pedwarn ("empty declaration"); }
- ;
-
-myparms:
- myparm
- { push_parm_decl ($1); }
- | myparms ',' myparm
- { push_parm_decl ($3); }
- ;
+/* Optional ObjC method parameters follow the C syntax, and may include '...'
+ to denote a variable number of arguments. */
-/* A single parameter declaration or parameter type name,
- as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
-
-myparm:
- parm_declarator maybe_attribute
- { $$ = build_tree_list (build_tree_list (current_declspecs,
- $1),
- chainon ($2, all_prefix_attributes)); }
- | notype_declarator maybe_attribute
- { $$ = build_tree_list (build_tree_list (current_declspecs,
- $1),
- chainon ($2, all_prefix_attributes)); }
- | absdcl_maybe_attribute
- { $$ = $1; }
+optparmlist:
+ optparms optellipsis
+ {
+ TREE_OVERFLOW ($$) = $2;
+ }
;
-optparmlist:
- /* empty */
+optparms:
+ /* NULL */
{
- $$ = NULL_TREE;
+ $$ = make_node (TREE_LIST);
}
- | ',' ELLIPSIS
+ | optparms ',' parm
{
- /* oh what a kludge! */
- $$ = objc_ellipsis_node;
+ $$ = chainon ($1, build_tree_list (NULL_TREE,
+ grokparm ($3)));
}
- | ','
+ ;
+
+optellipsis:
+ /* NULL */
{
- push_scope ();
+ $$ = 0;
}
- parmlist_2
+ | ',' ELLIPSIS
{
- /* returns a tree list node generated by get_parm_info */
- $$ = $3;
- pop_scope ();
+ $$ = 1;
}
;
@@ -3038,14 +2927,40 @@ selector:
;
reservedwords:
- ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
+ ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
| SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
| GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
| TYPESPEC | TYPE_QUAL
;
+objc_qual:
+ OBJC_TYPE_QUAL
+ ;
+
+objc_quals:
+ objc_quals objc_qual
+ {
+ $$ = chainon ($1, build_tree_list (NULL_TREE, $2));
+ }
+ | /* NULL */
+ {
+ $$ = NULL_TREE;
+ }
+ ;
+
+objc_typename:
+ objc_quals typename
+ {
+ $$ = build_tree_list ($1, groktypename ($2));
+ }
+ | objc_quals
+ {
+ $$ = build_tree_list ($1, NULL_TREE);
+ }
+ ;
+
keyworddecl:
- selector ':' '(' typename ')' identifier
+ selector ':' '(' objc_typename ')' identifier
{
$$ = objc_build_keyword_decl ($1, $4, $6);
}
@@ -3055,7 +2970,7 @@ keyworddecl:
$$ = objc_build_keyword_decl ($1, NULL_TREE, $3);
}
- | ':' '(' typename ')' identifier
+ | ':' '(' objc_typename ')' identifier
{
$$ = objc_build_keyword_decl (NULL_TREE, $3, $5);
}
@@ -3337,12 +3252,12 @@ static const short rid_to_yy[RID_MAX] =
/* RID_MUTABLE */ 0,
/* ObjC */
- /* RID_IN */ TYPE_QUAL,
- /* RID_OUT */ TYPE_QUAL,
- /* RID_INOUT */ TYPE_QUAL,
- /* RID_BYCOPY */ TYPE_QUAL,
- /* RID_BYREF */ TYPE_QUAL,
- /* RID_ONEWAY */ TYPE_QUAL,
+ /* RID_IN */ OBJC_TYPE_QUAL,
+ /* RID_OUT */ OBJC_TYPE_QUAL,
+ /* RID_INOUT */ OBJC_TYPE_QUAL,
+ /* RID_BYCOPY */ OBJC_TYPE_QUAL,
+ /* RID_BYREF */ OBJC_TYPE_QUAL,
+ /* RID_ONEWAY */ OBJC_TYPE_QUAL,
/* C */
/* RID_INT */ TYPESPEC,