[objc-improvements-branch] PR objc/12309 fix
Ziemowit Laski
zlaski@apple.com
Fri Sep 19 23:04:00 GMT 2003
As promised, here is the fix for the problem that David reported.
While at it,
I also analyzed PR objc/12262 and happily discovered that the
objc-improvements-branch
already fixed it, but added the originator's test case in anyway.
My only obstacle to happiness is that Bugzilla won't let me change the
status of these
bugs, claiming I have insufficient privileges. :-(
After this is committed, I'll start preparing for the long-promised
merge to mainline.
Any ChangeLog suggestions? :-)
[gcc]
2003-09-19 Ziemowit Laski <zlaski@apple.com>
PR objc/12309
* objc/objc-act.c (lookup_and_install_protocols): Exclude
missing
protocols from list instead of returning error_mark_node.
[gcc/testsuite]
2003-09-19 Ziemowit Laski <zlaski@apple.com>
PR objc/12262
* objc.dg/method-12.m: New test.
PR objc/12309
* objc.dg/missing-proto-3.m: New test.
Index: gcc/objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.179.2.13
diff -c -3 -p -r1.179.2.13 objc-act.c
*** gcc/objc/objc-act.c 17 Sep 2003 03:28:27 -0000 1.179.2.13
--- gcc/objc/objc-act.c 19 Sep 2003 23:02:13 -0000
*************** check_protocol_recursively (tree proto,
*** 1055,1066 ****
}
}
static tree
lookup_and_install_protocols (tree protocols)
{
tree proto;
! tree prev = NULL;
! tree return_value = protocols;
for (proto = protocols; proto; proto = TREE_CHAIN (proto))
{
--- 1055,1068 ----
}
}
+ /* Look up PROTOCOLS, and return a list of those that are found.
+ If none are found, return NULL. */
+
static tree
lookup_and_install_protocols (tree protocols)
{
tree proto;
! tree return_value = NULL_TREE;
for (proto = protocols; proto; proto = TREE_CHAIN (proto))
{
*************** lookup_and_install_protocols (tree proto
*** 1068,1084 ****
tree p = lookup_protocol (ident);
if (!p)
! {
! error ("cannot find protocol declaration for `%s'",
! IDENTIFIER_POINTER (ident));
! return error_mark_node;
! }
else
! {
! /* Replace identifier with actual protocol node. */
! TREE_VALUE (proto) = p;
! prev = proto;
! }
}
return return_value;
--- 1070,1080 ----
tree p = lookup_protocol (ident);
if (!p)
! error ("cannot find protocol declaration for `%s'",
! IDENTIFIER_POINTER (ident));
else
! return_value = chainon (return_value,
! build_tree_list (NULL_TREE, p));
}
return return_value;
Index: gcc/testsuite/objc.dg//method-12.m
===================================================================
RCS file: gcc/testsuite/objc.dg//method-12.m
diff -N gcc/testsuite/objc.dg//method-12.m
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/objc.dg//method-12.m 19 Sep 2003 23:02:14 -0000
***************
*** 0 ****
--- 1,25 ----
+ /* Contributed by Igor Seleznev <selez@mail.ru>. */
+ /* This used to be broken. */
+
+ #include <objc/objc-api.h>
+
+ @interface A
+ + (A *)currentContext;
+ @end
+
+ @interface B
+ + (B *)currentContext;
+ @end
+
+ int main()
+ {
+ [A currentContext]; /* { dg-bogus "multiple declarations" } */
+ return 0;
+ }
+
+ @implementation A
+ + (A *)currentContext { return nil; }
+ @end
+ @implementation B
+ + (B *)currentContext { return nil; }
+ @end
Index: gcc/testsuite/objc.dg//missing-proto-3.m
===================================================================
RCS file: gcc/testsuite/objc.dg//missing-proto-3.m
diff -N gcc/testsuite/objc.dg//missing-proto-3.m
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/objc.dg//missing-proto-3.m 19 Sep 2003 23:02:14
-0000
***************
*** 0 ****
--- 1,26 ----
+ /* Ensure that the compiler gracefully handles missing protocol
declarations.
+ In addition to not crashing :-), the compiler should properly
handle
+ valid protocol references, even when they're mixed with invalid
ones. */
+ /* { dg-do compile } */
+
+ #include <objc/objc.h>
+
+ @protocol DefinedProtocol
+ - (id) missingMethod1;
+ @end
+
+ @interface MyClass <UndefinedProtocol, DefinedProtocol>
+ /* { dg-error "cannot find protocol declaration for
.UndefinedProtocol." "" { target *-*-* } 12 } */
+ @end
+
+ @implementation MyClass
+ +(Class)class
+ {
+ return self;
+ }
+ @end
+
+ /* { dg-warning "incomplete implementation of class .MyClass." "" {
target *-*-* } 21 } */
+ /* { dg-warning "method definition for .\\-missingMethod1. not found"
"" { target *-*-* } 21 } */
+ /* { dg-warning "class .MyClass. does not fully implement the
.DefinedProtocol. protocol" "" { target *-*-* } 21 } */
+
--------------------------------------------------------------
Ziemowit Laski 1 Infinite Loop, MS 301-2K
Mac OS X Compiler Group Cupertino, CA USA 95014-2083
Apple Computer, Inc. +1.408.974.6229 Fax .5477
More information about the Gcc-patches
mailing list