Index: testsuite/g++.dg/other/dtor1.C =================================================================== --- testsuite/g++.dg/other/dtor1.C (revision 0) +++ testsuite/g++.dg/other/dtor1.C (revision 0) @@ -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; +} 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,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" } */ 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,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" } */ Index: cp/decl.c =================================================================== --- cp/decl.c (revision 129297) +++ cp/decl.c (working copy) @@ -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. */