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  <paolo.carlini@oracle.com>

	PR c++/70466
	* call.c (convert_like_real): Check that we are actually converting
	from an init list.

/testsuite
2016-05-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/70466
	* g++.dg/template/pr70466-1.C: New.
	* g++.dg/template/pr70466-2.C: Likewise.

From-SVN: r236395
This commit is contained in:
Paolo Carlini 2016-05-18 14:18:06 +00:00 committed by Paolo Carlini
parent 50c78b9ab3
commit 20309c6e2f
5 changed files with 66 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2016-05-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/70466
* call.c (convert_like_real): Check that we are actually converting
from an init list.
2016-05-16 Matthew Wahab <matthew.wahab@arm.com>
* decl.c (grokdeclarator): Remove errmsg and use of

View File

@ -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)
{

View File

@ -1,3 +1,9 @@
2016-05-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/70466
* g++.dg/template/pr70466-1.C: New.
* g++.dg/template/pr70466-2.C: Likewise.
2016-05-18 Michael Meissner <meissner@linux.vnet.ibm.com>
* gcc.target/powerpc/p9-splat-1.c: New tests for ISA 3.0 word

View File

@ -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;
}

View File

@ -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;
}