From e5e691a53fe4d2fd6e437d754fae75c4804c0256 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 3 Aug 2017 09:26:17 +0000 Subject: [PATCH] re PR c++/71440 (ICE on invalid C++ code in instantiate_type, at cp/class.c:8247) /cp 2017-08-03 Paolo Carlini PR c++/71440 * typeck.c (build_x_unary_op): Avoid pretty-printing constructor / destructor as expressions. /testsuite 2017-08-03 Paolo Carlini PR c++/71440 * g++.dg/template/crash127.C: New. From-SVN: r250848 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/typeck.c | 6 +++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/crash127.C | 22 ++++++++++++++++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/crash127.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8be42940bd8..041c6c44bbe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-08-03 Paolo Carlini + + PR c++/71440 + * typeck.c (build_x_unary_op): Avoid pretty-printing constructor / + destructor as expressions. + 2017-08-02 Jakub Jelinek PR c++/81640 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 3dc64045e1a..a58de1d6206 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5487,9 +5487,9 @@ build_x_unary_op (location_t loc, enum tree_code code, cp_expr xarg, { if (complain & tf_error) error (DECL_CONSTRUCTOR_P (fn) - ? G_("taking address of constructor %qE") - : G_("taking address of destructor %qE"), - xarg.get_value ()); + ? G_("taking address of constructor %qD") + : G_("taking address of destructor %qD"), + fn); return error_mark_node; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a8077a53341..58e1b87c6dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-08-03 Paolo Carlini + + PR c++/71440 + * g++.dg/template/crash127.C: New. + 2017-08-03 Jakub Jelinek PR middle-end/81052 diff --git a/gcc/testsuite/g++.dg/template/crash127.C b/gcc/testsuite/g++.dg/template/crash127.C new file mode 100644 index 00000000000..b7c03251f8c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash127.C @@ -0,0 +1,22 @@ +// PR c++/71440 + +struct A +{ + void f () {} +}; + +typedef void (A::*Ptr) (); + +template < Ptr > struct B {}; + +template < class T > +struct C : public A +{ + void bar () + { + B < &A::A > b; // { dg-error "taking address of constructor 'A::A" "" { target c++98_only } } + // { dg-error "taking address of constructor 'constexpr A::A" "" { target c++11 } .-1 } + } +}; + +template class C < int >; -- 2.30.2