From 20309c6e2f8a3dcd1edb66f8f95669e174183403 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 18 May 2016 14:18:06 +0000 Subject: [PATCH] re PR c++/70466 ([ICE on invalid code in tree check: expected constructor, have parm_decl in convert_like_real, at cp/call.c:6371 with -std=c++11) /cp 2016-05-18 Paolo Carlini PR c++/70466 * call.c (convert_like_real): Check that we are actually converting from an init list. /testsuite 2016-05-18 Paolo Carlini PR c++/70466 * g++.dg/template/pr70466-1.C: New. * g++.dg/template/pr70466-2.C: Likewise. From-SVN: r236395 --- gcc/cp/ChangeLog | 6 +++++ gcc/cp/call.c | 3 ++- gcc/testsuite/ChangeLog | 6 +++++ gcc/testsuite/g++.dg/template/pr70466-1.C | 27 +++++++++++++++++++++++ gcc/testsuite/g++.dg/template/pr70466-2.C | 25 +++++++++++++++++++++ 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/pr70466-1.C create mode 100644 gcc/testsuite/g++.dg/template/pr70466-2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1884bc9c52d..4dc67551c85 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-05-18 Paolo Carlini + + PR c++/70466 + * call.c (convert_like_real): Check that we are actually converting + from an init list. + 2016-05-16 Matthew Wahab * decl.c (grokdeclarator): Remove errmsg and use of diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 0b59c403b31..729b7eb4ba3 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -6377,8 +6377,9 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, /* When converting from an init list we consider explicit constructors, but actually trying to call one is an error. */ if (DECL_NONCONVERTING_P (convfn) && DECL_CONSTRUCTOR_P (convfn) + && BRACE_ENCLOSED_INITIALIZER_P (expr) /* Unless this is for direct-list-initialization. */ - && !DIRECT_LIST_INIT_P (expr) + && !CONSTRUCTOR_IS_DIRECT_INIT (expr) /* And in C++98 a default constructor can't be explicit. */ && cxx_dialect >= cxx11) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d77545d03bd..e06f7e4734a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-05-18 Paolo Carlini + + PR c++/70466 + * g++.dg/template/pr70466-1.C: New. + * g++.dg/template/pr70466-2.C: Likewise. + 2016-05-18 Michael Meissner * gcc.target/powerpc/p9-splat-1.c: New tests for ISA 3.0 word diff --git a/gcc/testsuite/g++.dg/template/pr70466-1.C b/gcc/testsuite/g++.dg/template/pr70466-1.C new file mode 100644 index 00000000000..7eb83eab957 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr70466-1.C @@ -0,0 +1,27 @@ +// PR c++/70466 + +template < class T, class T > // { dg-error "conflicting" } +class A +{ +public: + explicit A (T (S::*f) ()) {} // { dg-error "expected" } +}; + +template < class T, class S > +A < T, S > foo (T (S::*f) ()) +{ + return A < T, S > (f); +} + +class B +{ +public: + void bar () {} +}; + +int +main () +{ + foo (&B::bar); + return 0; +} diff --git a/gcc/testsuite/g++.dg/template/pr70466-2.C b/gcc/testsuite/g++.dg/template/pr70466-2.C new file mode 100644 index 00000000000..7a7458a61f1 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr70466-2.C @@ -0,0 +1,25 @@ +// PR c++/70466 + +template < class T, class S > +struct A +{ + explicit A (...) {} +}; + +template < class T, class S > +A < T, S > foo (T (S::*f) ()) +{ + return A < T, S > (f); +} + +struct B +{ + void bar () {} +}; + +int +main () +{ + foo (&B::bar); + return 0; +} -- 2.30.2