gcc/cp/ChangeLog:
PR c++/68948
* pt.c (tsubst_baselink): Diagnose an invalid constructor call
if lookup_fnfields returns NULL_TREE and the name being looked
up has the form A::A.
gcc/testsuite/ChangeLog:
PR c++/68948
* g++.dg/template/pr68948.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233176
138bc75d-0d04-0410-961f-
82ee72b054a4
+2016-02-05 Patrick Palka <ppalka@gcc.gnu.org>
+
+ PR c++/68948
+ * pt.c (tsubst_baselink): Diagnose an invalid constructor call
+ if lookup_fnfields returns NULL_TREE and the name being looked
+ up has the form A::A.
+
2016-02-04 Patrick Palka <ppalka@gcc.gnu.org>
* constexpr.c (cxx_eval_binary_expression): Fold equality
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
+2016-02-05 Patrick Palka <ppalka@gcc.gnu.org>
+
+ PR c++/68948
+ * g++.dg/template/pr68948.C: New test.
+
2016-02-05 Dominik Vogt <vogt@linux.vnet.ibm.com>
* gcc.dg/tree-ssa/ssa-dom-cse-2.c: Remove -march=z13 for s390
--- /dev/null
+// PR c++/68948
+
+struct B { B (); B (int); };
+
+struct Time : B { };
+
+/* Here, A and B are unrelated types. */
+
+template <typename>
+struct A
+{
+ void TestBody ()
+ {
+ B::B (); // { dg-error "cannot call constructor .B::B." }
+ B::B::B (); // { dg-error "cannot call constructor .B::B." }
+ B::B (0); // { dg-error "cannot call constructor .B::B." }
+ }
+};
+
+/* Here, C is (indirectly) derived from B. */
+
+template <typename g>
+struct C : Time
+{
+ void TestBody ()
+ {
+ B::B (); // { dg-error "cannot call constructor .B::B." }
+ B::B::B (); // { dg-error "cannot call constructor .B::B." }
+ B::B (0); // { dg-error "cannot call constructor .B::B." }
+ Time::B (0);
+ }
+};
+
+int
+main (void)
+{
+ A<int> a;
+ C<int> c;
+ a.TestBody ();
+ c.TestBody ();
+}