From: Paolo Carlini Date: Tue, 9 May 2017 16:56:34 +0000 (+0000) Subject: re PR c++/80186 (ICE on C++ code with invalid constructor: Segmentation fault (progra... X-Git-Tag: basepoints/gcc-9~7458 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc49d15a181ae51828fb6c3984b1d878eed5fba1;p=thirdparty%2Fgcc.git re PR c++/80186 (ICE on C++ code with invalid constructor: Segmentation fault (program cc1plus)) /cp 2017-05-09 Paolo Carlini PR c++/80186 * pt.c (tsubst_decl): Early return error_mark_node if grok_ctor_properties returns false. /testsuite 2017-05-09 Paolo Carlini PR c++/80186 * g++.dg/template/crash126.C: New. From-SVN: r247807 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a5990e2a6c25..6b899d19804c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-05-09 Paolo Carlini + + PR c++/80186 + * pt.c (tsubst_decl): Early return error_mark_node if + grok_ctor_properties returns false. + 2017-05-09 Jason Merrill PR c++/70167 - array prvalue treated as lvalue diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a4a0d83503a7..0a8298c98f21 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12407,8 +12407,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) if (DECL_CONSTRUCTOR_P (r) || DECL_DESTRUCTOR_P (r)) { maybe_retrofit_in_chrg (r); - if (DECL_CONSTRUCTOR_P (r)) - grok_ctor_properties (ctx, r); + if (DECL_CONSTRUCTOR_P (r) && !grok_ctor_properties (ctx, r)) + RETURN (error_mark_node); /* If this is an instantiation of a member template, clone it. If it isn't, that'll be handled by clone_constructors_and_destructors. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d0c083d34946..68d9e3fbe2ac 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-05-09 Paolo Carlini + + PR c++/80186 + * g++.dg/template/crash126.C: New. + 2017-05-09 Sebastian Peryt * gcc.target/i386/avx512f-vaddsd-2.c: Test fixed. diff --git a/gcc/testsuite/g++.dg/template/crash126.C b/gcc/testsuite/g++.dg/template/crash126.C new file mode 100644 index 000000000000..8a3112e23442 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash126.C @@ -0,0 +1,13 @@ +// PR c++/80186 + +template < class T, class > struct A +{ + A (); + A (A &); + A (A < T, T >); // { dg-error "invalid constructor" } +}; + +void f () +{ + A < int, int > (A < int, int >()); // { dg-error "cannot bind" } +}