This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR 29016
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Sep 2006 15:24:27 -0700
- Subject: C++ PATCH: PR 29016
- Reply-to: mark at codesourcery dot com
This patch fixes PR c++/29016, an ICE that occurs because the
middle-end got confused when it saw a BASELINK as an initializer for a
global variable.
Although this patch fixes the problem, by ensuring that the middle-end
never sees the BASELINK, there's still an unresolved design issue. In
the old days, variable initializers for variables with static storage
duration were ignored by the middle end. The only consumer was
varasm.c, which handled actually emitting them as assembly code. That
code makes some callbacks into the language front end (via things like
"staticp" and "lang_hooks.expand_constant") to get generic trees that
can be assembled.
Now, however, the middle-end actually wants to poke at the
initializers. That means that we should better defined the
initializers. Presumably, we should eliminate the hooks mentioned
above, and just mandate that initializers be GENERIC. (These are, by
definition, initializers for variables with static storage duration,
so they have no executable code; they're just data.)
Tested on x86_64-unknown-linux-gnu, applied on the mainline.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
2006-09-21 Mark Mitchell <mark@codesourcery.com>
PR c++/29016
* typeck.c (build_unary_op): Don't form an ADDR_EXPR around a
BASELINK.
2006-09-21 Mark Mitchell <mark@codesourcery.com>
PR c++/29016
* g++.dg/init/ptrfn1.C: New test.
Index: gcc/cp/typeck.c
===================================================================
--- gcc/cp/typeck.c (revision 117106)
+++ gcc/cp/typeck.c (working copy)
@@ -4311,6 +4311,10 @@ build_unary_op (enum tree_code code, tre
pedwarn ("ISO C++ forbids taking the address of a cast to a non-lvalue expression");
break;
+ case BASELINK:
+ arg = BASELINK_FUNCTIONS (arg);
+ /* Fall through. */
+
case OVERLOAD:
arg = OVL_CURRENT (arg);
break;
Index: gcc/testsuite/g++.dg/init/ptrfn1.C
===================================================================
--- gcc/testsuite/g++.dg/init/ptrfn1.C (revision 0)
+++ gcc/testsuite/g++.dg/init/ptrfn1.C (revision 0)
@@ -0,0 +1,12 @@
+// PR c++/29016
+// { dg-options "-O2" }
+
+class A;
+class B
+{
+ typedef void (*C[5]) (A *);
+ static C D;
+ static void E (A*) {}
+};
+B::C B::D={E};
+