diff options
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r-- | gcc/objc/objc-act.c | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index d8fbe368a78..e98890629c2 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -20,26 +20,6 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ - -/* Purpose: This module implements the Objective-C 4.0 language. - - compatibility issues (with the Stepstone translator): - - - does not recognize the following 3.3 constructs. - @requires, @classes, @messages, = (...) - - methods with variable arguments must conform to ANSI standard. - - tagged structure definitions that appear in BOTH the interface - and implementation are not allowed. - - public/private: all instance variables are public within the - context of the implementation...I consider this to be a bug in - the translator. - - statically allocated objects are not supported. the user will - receive an error if this service is requested. - - code generation `options': - - */ - #include "config.h" #include "system.h" #include "coretypes.h" @@ -371,6 +351,8 @@ int objc_public_flag; /* Use to generate method labels. */ static int method_slot = 0; +static int objc_collecting_ivars = 0; + #define BUFSIZE 1024 static char *errbuf; /* Buffer for error diagnostics */ @@ -775,18 +757,30 @@ void objc_add_method_declaration (tree decl) { if (!objc_interface_context) - fatal_error ("method declaration not in @interface context"); + { + /* PS: At the moment, due to how the parser works, it should be + impossible to get here. But it's good to have the check in + case the parser changes. + */ + fatal_error ("method declaration not in @interface context"); + } objc_add_method (objc_interface_context, decl, objc_inherit_code == CLASS_METHOD_DECL); } -void +/* Return 'true' if the method definition could be started, and + 'false' if not (because we are outside an @implementation context). +*/ +bool objc_start_method_definition (tree decl) { if (!objc_implementation_context) - fatal_error ("method definition not in @implementation context"); + { + error ("method definition not in @implementation context"); + return false; + } #ifndef OBJCPLUS /* Indicate no valid break/continue context by setting these variables @@ -799,6 +793,7 @@ objc_start_method_definition (tree decl) decl, objc_inherit_code == CLASS_METHOD_DECL); start_method_def (decl); + return true; } void @@ -3453,6 +3448,21 @@ objc_get_class_ivars (tree class_name) return error_mark_node; } +/* Called when checking the variables in a struct. If we are not + doing the ivars list inside an @interface context, then returns + fieldlist unchanged. Else, returns the list of class ivars. +*/ +tree +objc_get_interface_ivars (tree fieldlist) +{ + if (!objc_collecting_ivars || !objc_interface_context + || TREE_CODE (objc_interface_context) != CLASS_INTERFACE_TYPE + || CLASS_SUPER_NAME (objc_interface_context) == NULL_TREE) + return fieldlist; + + return get_class_ivars (objc_interface_context, true); +} + /* Used by: build_private_template, continue_class, and for @defs constructs. */ @@ -7714,7 +7724,9 @@ continue_class (tree klass) push_lang_context (lang_name_c); #endif /* OBJCPLUS */ + objc_collecting_ivars = 1; build_private_template (klass); + objc_collecting_ivars = 0; #ifdef OBJCPLUS pop_lang_context (); |