This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++/PATCH] Fix PR 30303, ICE with invalid constructor definition
- From: Andrew Pinski <pinskia at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 07 Jan 2007 20:51:27 -0800
- Subject: [C++/PATCH] Fix PR 30303, ICE with invalid constructor definition
The problem here is that grokfndecl errors but does not return NULL for
the case of defining a constructor that was implicitly declared.
OK? Bootstrapped and tested on i686-linux-gnu with no regressions.
Thanks,
Andrew Pinski
* decl.c (grokfndecl): Return NULL after the "definition of
implicitly-declared" error happened.
* g++.dg/other/ctor1.C: New test.
* g++.dg/other/ctor2.C: New test.
Index: testsuite/g++.dg/other/ctor1.C
===================================================================
--- testsuite/g++.dg/other/ctor1.C (revision 0)
+++ testsuite/g++.dg/other/ctor1.C (revision 0)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+// PR C++/30303
+// This used to ICE because we did not return NULL
+// in grokfndecl when an error happened.
+
+
+
+class A
+{
+ int i;
+};
+
+A::A() { A(); } /* { dg-error "definition of implicitly-declared" } */
Index: testsuite/g++.dg/other/ctor2.C
===================================================================
--- testsuite/g++.dg/other/ctor2.C (revision 0)
+++ testsuite/g++.dg/other/ctor2.C (revision 0)
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+// PR C++/30303
+// This used to ICE because we did not return NULL
+// in grokfndecl when an error happened.
+
+
+
+class A
+{
+ int i;
+};
+
+void foo()
+{
+ A();
+}
+
+A::A() {} /* { dg-error "definition of implicitly-declared" } */
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 120543)
+++ cp/decl.c (working copy)
@@ -6223,7 +6223,10 @@ grokfndecl (tree ctype,
XXX Isn't this done in start_function, too? */
revert_static_member_fn (decl);
if (DECL_ARTIFICIAL (old_decl))
- error ("definition of implicitly-declared %qD", old_decl);
+ {
+ error ("definition of implicitly-declared %qD", old_decl);
+ return NULL_TREE;
+ }
/* Since we've smashed OLD_DECL to its
DECL_TEMPLATE_RESULT, we must do the same to DECL. */