This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch: PR c++/30297
- From: Tom Tromey <tromey at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 08 Nov 2007 09:24:24 -0700
- Subject: Patch: PR c++/30297
- Reply-to: tromey at redhat dot com
This patch fixes PR c++/30297.
The bug is that g++ will ICE when a FIELD_DECL is passed to
decl_linkage. The patch changes decl_linkage to handle this
situation.
Andrew Pinski's name is on the ChangeLog entry because he wrote this
patch; it is the one that appears in the PR. I just added the test
case and tested it.
Bootstrapped and regtested on x86 FC-6. Ok?
Tom
:ADDPATCH C++:
gcc/ChangeLog:
2007-11-08 Andrew Pinski <pinskia@gmail.com>
PR c++/30297:
* tree.c (decl_linkage): Fields have no linkage.
testsuite/ChangeLog:
2007-11-08 Tom Tromey <tromey@redhat.com>
PR c++/30297:
* g++.dg/inherit/pr30297.C: New file.
Index: testsuite/g++.dg/inherit/pr30297.C
===================================================================
--- testsuite/g++.dg/inherit/pr30297.C (revision 0)
+++ testsuite/g++.dg/inherit/pr30297.C (revision 0)
@@ -0,0 +1,11 @@
+// Regression test for ICE from PR c++/30297.
+
+struct A
+{
+ int i;
+};
+
+extern "C" struct B : A
+{
+ A::i;
+};
Index: cp/tree.c
===================================================================
--- cp/tree.c (revision 130004)
+++ cp/tree.c (working copy)
@@ -2493,6 +2493,10 @@
if (!DECL_NAME (decl))
return lk_none;
+ /* Fields have no linkage. */
+ if (TREE_CODE (decl) == FIELD_DECL)
+ return lk_none;
+
/* Things that are TREE_PUBLIC have external linkage. */
if (TREE_PUBLIC (decl))
return lk_external;