* Patch for objc/23710
@ 2010-09-19 8:36 Nicola Pero
2010-09-20 7:42 ` Mike Stump
2010-09-22 8:59 ` Eric Botcazou
0 siblings, 2 replies; 6+ messages in thread
From: Nicola Pero @ 2010-09-19 8:36 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 202 bytes --]
This patch fixes objc/23710 ("objc front-end should not
"abort" after erroring out about method definition not in
class context).
OK to apply ?
Thanks
PS: This is not a merge, it's new code
[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 5676 bytes --]
Index: gcc/c-family/c-common.h
===================================================================
--- gcc/c-family/c-common.h (revision 164389)
+++ gcc/c-family/c-common.h (working copy)
@@ -975,7 +975,7 @@ extern void objc_set_visibility (int);
extern void objc_set_method_type (enum tree_code);
extern tree objc_build_method_signature (tree, tree, tree, bool);
extern void objc_add_method_declaration (tree);
-extern void objc_start_method_definition (tree);
+extern bool objc_start_method_definition (tree);
extern void objc_finish_method_definition (tree);
extern void objc_add_instance_variable (tree);
extern tree objc_build_keyword_decl (tree, tree, tree);
Index: gcc/c-family/stub-objc.c
===================================================================
--- gcc/c-family/stub-objc.c (revision 164389)
+++ gcc/c-family/stub-objc.c (working copy)
@@ -184,9 +184,10 @@ objc_add_method_declaration (tree ARG_UNUSED (sign
{
}
-void
+bool
objc_start_method_definition (tree ARG_UNUSED (signature))
{
+ return true;
}
void
Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c (revision 164389)
+++ gcc/objc/objc-act.c (working copy)
@@ -775,18 +775,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 +811,7 @@ objc_start_method_definition (tree decl)
decl,
objc_inherit_code == CLASS_METHOD_DECL);
start_method_def (decl);
+ return true;
}
void
Index: gcc/objc/ChangeLog
===================================================================
--- gcc/objc/ChangeLog (revision 164389)
+++ gcc/objc/ChangeLog (working copy)
@@ -1,3 +1,10 @@
+2010-09-18 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-15 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers.
Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog (revision 164389)
+++ gcc/ChangeLog (working copy)
@@ -1,3 +1,14 @@
+2010-09-19 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ PR/objc 23710
+ * 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.
+
2010-09-17 Sebastian Pop <sebastian.pop@amd.com>
* graphite-dependences.c (dot_deps): Add DEBUG_FUNCTION.
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (revision 164389)
+++ gcc/testsuite/ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2010-09-18 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ PR/objc 23710
+ * objc.dg/invalid-method-1.m: New.
+
2010-09-17 H.J. Lu <hongjiu.lu@intel.com>
* gcc.target/i386/pad-1.c: New.
Index: gcc/testsuite/objc.dg/invalid-method-1.m
===================================================================
--- gcc/testsuite/objc.dg/invalid-method-1.m (revision 0)
+++ gcc/testsuite/objc.dg/invalid-method-1.m (revision 0)
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* Test that we keep compiling if a method definition is found outside
+ of an @implementation context.
+*/
+
++ (void)C { } /* { dg-error "method definition not in @implementation context" } */
+
+/* We have another error here to test that the compiler is still going and
+ finding errors in the rest of the code.
+*/
+@compatibility_alias class1 class2; /* { dg-warning "annot find class" } */
Index: gcc/c-parser.c
===================================================================
--- gcc/c-parser.c (revision 164389)
+++ gcc/c-parser.c (working copy)
@@ -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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Patch for objc/23710
2010-09-19 8:36 Patch for objc/23710 Nicola Pero
@ 2010-09-20 7:42 ` Mike Stump
2010-09-22 8:59 ` Eric Botcazou
1 sibling, 0 replies; 6+ messages in thread
From: Mike Stump @ 2010-09-20 7:42 UTC (permalink / raw)
To: Nicola Pero; +Cc: gcc-patches
On Sep 18, 2010, at 4:52 PM, Nicola Pero wrote:
> This patch fixes objc/23710 ("objc front-end should not
> "abort" after erroring out about method definition not in
> class context).
>
> OK to apply ?
Ok.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Patch for objc/23710
2010-09-19 8:36 Patch for objc/23710 Nicola Pero
2010-09-20 7:42 ` Mike Stump
@ 2010-09-22 8:59 ` Eric Botcazou
2010-09-22 9:24 ` Nicola Pero
1 sibling, 1 reply; 6+ messages in thread
From: Eric Botcazou @ 2010-09-22 8:59 UTC (permalink / raw)
To: Nicola Pero; +Cc: gcc-patches
> This patch fixes objc/23710 ("objc front-end should not
> "abort" after erroring out about method definition not in
> class context).
Please post ChangeLog in the body of the message.
Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog (revision 164389)
+++ gcc/ChangeLog (working copy)
@@ -1,3 +1,14 @@
+2010-09-19 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ PR/objc 23710
+ * 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.
c-family/ has its own ChangeLog so the first 2 entries must be moved to there
without the prefix.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Patch for objc/23710
2010-09-22 8:59 ` Eric Botcazou
@ 2010-09-22 9:24 ` Nicola Pero
2010-09-22 14:57 ` Eric Botcazou
0 siblings, 1 reply; 6+ messages in thread
From: Nicola Pero @ 2010-09-22 9:24 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches
> Please post ChangeLog in the body of the message.
Sure, will do
> c-family/ has its own ChangeLog so the first 2 entries must be moved to there
> without the prefix.
Ok, I fixed the problem.
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Patch for objc/23710
2010-09-22 9:24 ` Nicola Pero
@ 2010-09-22 14:57 ` Eric Botcazou
2010-09-22 15:15 ` Nicola Pero
0 siblings, 1 reply; 6+ messages in thread
From: Eric Botcazou @ 2010-09-22 14:57 UTC (permalink / raw)
To: Nicola Pero; +Cc: gcc-patches
> Ok, I fixed the problem.
Thanks. There is another one just below though. :-)
--
Eric Botcazou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Patch for objc/23710
2010-09-22 14:57 ` Eric Botcazou
@ 2010-09-22 15:15 ` Nicola Pero
0 siblings, 0 replies; 6+ messages in thread
From: Nicola Pero @ 2010-09-22 15:15 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches
>> Ok, I fixed the problem.
>
> Thanks. There is another one just below though. :-)
Ok ... I addressed that one as well.
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-09-22 7:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-19 8:36 Patch for objc/23710 Nicola Pero
2010-09-20 7:42 ` Mike Stump
2010-09-22 8:59 ` Eric Botcazou
2010-09-22 9:24 ` Nicola Pero
2010-09-22 14:57 ` Eric Botcazou
2010-09-22 15:15 ` Nicola Pero
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).