aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/call.cc4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/explicit16.C18
2 files changed, 21 insertions, 1 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index c01e7b8..c52a09b 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -3612,7 +3612,9 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
/* Now the explicit specifier might have been deduced; check if this
declaration is explicit. If it is and we're ignoring non-converting
constructors, don't add this function to the set of candidates. */
- if ((flags & LOOKUP_ONLYCONVERTING) && DECL_NONCONVERTING_P (fn))
+ if (((flags & (LOOKUP_ONLYCONVERTING|LOOKUP_LIST_INIT_CTOR))
+ == LOOKUP_ONLYCONVERTING)
+ && DECL_NONCONVERTING_P (fn))
return NULL;
if (DECL_CONSTRUCTOR_P (fn) && nargs == 2)
diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit16.C b/gcc/testsuite/g++.dg/cpp0x/explicit16.C
new file mode 100644
index 0000000..bb5a823
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/explicit16.C
@@ -0,0 +1,18 @@
+// PR c++/109159
+// { dg-do compile { target c++11 } }
+
+struct A {
+ A(float) {}
+ template<class U>
+ explicit A(U) {}
+};
+
+void f(A t)
+{
+ t = {1}; // { dg-error "explicit constructor" }
+ t = 1;
+ A a1{1};
+ A a2 = {1}; // { dg-error "explicit constructor" }
+ A a3 = 1;
+ A a4(1);
+}