Commit 76c85fbb by Patrick Palka

Fix PR c++/68948 (wrong code generation due to invalid constructor call)

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.

From-SVN: r233176
parent dfcfe184
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
......
......@@ -13583,7 +13583,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
......
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
......
// 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 ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment