]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/30303 (ICE with invalid constructor definition)
authorAndrew Pinski <pinskia@gmail.com>
Sun, 14 Oct 2007 18:15:35 +0000 (11:15 -0700)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sun, 14 Oct 2007 18:15:35 +0000 (11:15 -0700)
2007-10-14  Andrew Pinski  <pinskia@gmail.com>

        PR c++/30303
        * decl.c (grokfndecl): Return NULL after the "definition of
        implicitly-declared" error happened.

2007-10-14  Andrew Pinski  <pinskia@gmail.com>

        PR c++/30303
        * g++.dg/other/ctor1.C: New test.
        * g++.dg/other/ctor2.C: New test.
        * g++.dg/other/dtor1.C: New test.

From-SVN: r129298

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/ctor1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/ctor2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/dtor1.C [new file with mode: 0644]

index bc25402a0e9d50159bed1f29e5dd6fa55848d8f6..b81f0e82b19aff9db04867c96b5280c4a1d4c44c 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-14  Andrew Pinski  <pinskia@gmail.com>
+
+       PR c++/30303
+       * decl.c (grokfndecl): Return NULL after the "definition of
+       implicitly-declared" error happened.
+
 2007-10-12  Simon Martin  <simartin@users.sourceforge.net>
 
        PR c++/26698
index 83195af1b49dec3a543df7f9a778befa02c6a421..5553ec1753ea2744c2351fb14e41373715167601 100644 (file)
@@ -6577,7 +6577,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.  */
index 157d2278a30298fb59572bc29a6957714d6f3d76..abfa7704ef7382068809820f5c4ccb3cf9a7d3b8 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-14  Andrew Pinski  <pinskia@gmail.com>
+
+        PR c++/30303
+       * g++.dg/other/ctor1.C: New test.
+       * g++.dg/other/ctor2.C: New test.
+       * g++.dg/other/dtor1.C: New test.
+
 2007-10-14  Tobias Burnus  <burnus@gcc.gnu.org>
 
        * gfortran.dg/bounds_check_10.f90: Fix testcase.
diff --git a/gcc/testsuite/g++.dg/other/ctor1.C b/gcc/testsuite/g++.dg/other/ctor1.C
new file mode 100644 (file)
index 0000000..65449f4
--- /dev/null
@@ -0,0 +1,11 @@
+/* { 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" } */
diff --git a/gcc/testsuite/g++.dg/other/ctor2.C b/gcc/testsuite/g++.dg/other/ctor2.C
new file mode 100644 (file)
index 0000000..65bd859
--- /dev/null
@@ -0,0 +1,17 @@
+/* { 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" } */
diff --git a/gcc/testsuite/g++.dg/other/dtor1.C b/gcc/testsuite/g++.dg/other/dtor1.C
new file mode 100644 (file)
index 0000000..90ca380
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+// PR C++/30303
+// This used to ICE because we did not return NULL
+// in grokfndecl when an error happened.
+
+struct Ifoo
+{
+virtual ~Ifoo(){}
+};
+struct foo : Ifoo
+{
+ foo(){};
+};
+foo::~foo() // { dg-error "definition of implicitly-declared" }
+{
+delete this;
+}