aboutsummaryrefslogtreecommitdiff
path: root/gcc/objc
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2010-09-21 20:47:04 +0000
committerNicola Pero <nicola@gcc.gnu.org>2010-09-21 20:47:04 +0000
commit45547c7fcaaf0cb104de351360032af45948db09 (patch)
treec7e866e855504d34b4f13d9b926527820acd5180 /gcc/objc
parentec5e67bf4f176448bfb868599cefb583110301f1 (diff)
downloadgcc-45547c7fcaaf0cb104de351360032af45948db09.zip
gcc-45547c7fcaaf0cb104de351360032af45948db09.tar.gz
gcc-45547c7fcaaf0cb104de351360032af45948db09.tar.bz2
re PR objc/23710 (objc front-end should not "abort" after erroring out about method definition not in class context)
PR objc/23710 In gcc/: * c-family/c-common.h (objc_start_method_definition): Return bool instead of void. * c-family/stub-objc.c (objc_start_method_definition): Return bool instead of void. * c-parser.c (c_parser_objc_method_definition): Check the return value of objc_start_method_definition and if false is returned, parse the method definition but emit no code. In gcc/objc/: * objc-act.c (objc_start_method_definition): Do not abort upon a 'method definition not in @implementation context' error. Return 'false' instead. In gcc/testsuite/: * objc.dg/invalid-method-1.m: New. From-SVN: r164497
Diffstat (limited to 'gcc/objc')
-rw-r--r--gcc/objc/ChangeLog7
-rw-r--r--gcc/objc/objc-act.c19
2 files changed, 23 insertions, 3 deletions
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index 87dcec8..8d5490e 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -1,5 +1,12 @@
2010-09-21 Nicola Pero <nicola.pero@meta-innovation.com>
+ PR objc/23710
+ * objc-act.c (objc_start_method_definition): Do not abort upon a
+ 'method definition not in @implementation context' error. Return
+ 'false' instead.
+
+2010-09-21 Nicola Pero <nicola.pero@meta-innovation.com>
+
PR objc/25965
* objc-act.c (objc_get_interface_ivars): New function.
(objc_collecting_ivars): New variable.
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 5794238..55e50f4 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -777,18 +777,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
@@ -801,6 +813,7 @@ objc_start_method_definition (tree decl)
decl,
objc_inherit_code == CLASS_METHOD_DECL);
start_method_def (decl);
+ return true;
}
void