@@ -13607,7 +13607,15 @@ tsubst_baselink (tree baselink, tree object_type,
name = mangle_conv_op_name_for_type (optype);
baselink = lookup_fnfields (qualifying_scope, name, /*protect=*/1);
if (!baselink)
- return error_mark_node;
+ {
+ if (constructor_name_p (name, qualifying_scope))
+ {
+ if (complain & tf_error)
+ error ("cannot call constructor %<%T::%D%> directly",
+ qualifying_scope, name);
+ }
+ return error_mark_node;
+ }
/* If lookup found a single function, mark it as used at this
point. (If it lookup found multiple functions the one selected
new file mode 100644
@@ -0,0 +1,25 @@
+// PR c++/69961
+// { dg-do compile { target c++11 } }
+
+#include <string>
+
+using std::string;
+
+class Format {
+ public:
+ explicit Format(string formatted) {}
+ string buffer;
+};
+
+string StrCat(const string& a) {
+ return "";
+}
+
+template <typename... AV>
+Format Message(string msg, const AV&... args) {
+ return Format::Format(StrCat(msg, args...)); // { dg-error "cannot call constructor" }
+}
+
+int main(int, char**) {
+ Message("msg");
+}
new file mode 100644
@@ -0,0 +1,15 @@
+// PR c++/69961
+
+struct A { A (int); };
+
+template <typename T>
+void foo ()
+{
+ A::A ((T)0); // { dg-error "cannot call constructor .A::A. directly" }
+}
+
+void
+bar ()
+{
+ foo<int> ();
+}