[patch] Fix PR objc/27240: ICE with member of undefined struct
Volker Reichelt
reichelt@igpm.rwth-aachen.de
Thu May 4 12:16:00 GMT 2006
The objc frontend stumbles over the following invalid testcase:
void foo()
{
struct A a;
a.i;
}
It tries figure out whether "a.i" is accessible or not. That doesn't work
as expected because "struct A" isn't defined, i.e. the variable "a" has
error_mark_node as type:
bug.m: In function 'foo':
bug.m:3: error: storage size of 'a' isn't known
bug.m:4: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in objc_is_public, at objc/objc-act.c:7171
Please submit a full bug report, [etc.]
The following patch fixes that by returning "1" (indicating that the
member is public) on invalid types.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline?
Regards,
Volker
:ADDPATCH objc:
2006-05-04 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR objc/27240
* objc-act.c (objc_is_public): Return early on invalid type.
===================================================================
--- gcc/gcc/objc/objc-act.c (revision 113130)
+++ gcc/gcc/objc/objc-act.c (working copy)
@@ -7168,6 +7168,9 @@ objc_is_public (tree expr, tree identifier)
return 1;
#endif
+ if (TREE_TYPE (expr) == error_mark_node)
+ return 1;
+
basetype = TYPE_MAIN_VARIANT (TREE_TYPE (expr));
if (basetype && TREE_CODE (basetype) == RECORD_TYPE)
===================================================================
2006-05-04 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR objc/27240
* objc.dg/member-1.m: New test.
===================================================================
--- gcc/gcc/testsuite/objc.dg/member-1.m 2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/objc.dg/member-1.m 2006-05-04 13:05:17 +0200
@@ -0,0 +1,5 @@
+void foo()
+{
+ struct A a; /* { dg-error "storage size" } */
+ a.i;
+}
===================================================================
More information about the Gcc-patches
mailing list