aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-parser.c
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/c-parser.c
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/c-parser.c')
-rw-r--r--gcc/c-parser.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index 666f418..b1e6eb2 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -6597,9 +6597,19 @@ c_parser_objc_method_definition (c_parser *parser)
return;
}
parser->objc_pq_context = false;
- objc_start_method_definition (decl);
- add_stmt (c_parser_compound_statement (parser));
- objc_finish_method_definition (current_function_decl);
+ if (objc_start_method_definition (decl))
+ {
+ add_stmt (c_parser_compound_statement (parser));
+ objc_finish_method_definition (current_function_decl);
+ }
+ else
+ {
+ /* This code is executed when we find a method definition
+ outside of an @implementation context. Parse the method (to
+ keep going) but do not emit any code.
+ */
+ c_parser_compound_statement (parser);
+ }
}
/* Parse an objc-methodprotolist.