Commit 89606913 by Jason Merrill Committed by Jason Merrill

call.c (struct conversion_info): Rename 'from_type' to 'from'.

	* call.c (struct conversion_info): Rename 'from_type' to 'from'.
	(arg_conversion_rejection, bad_arg_conversion_rejection)
	(explicit_conversion_rejection, template_conversion_rejection): Adjust.
	(add_function_candidate): Pass actual argument, rather than type, to
	bad_arg_conversion_rejection.
	(print_conversion_rejection): Explain what's wrong with the conversion.
	(print_z_candidate): Say "candidate:" before each candidate.
	(splice_viable): Be strict if we see a viable or template candidate.
	(build_user_type_conversion_1): Pass false to strict parameter.
	(perform_overload_resolution, build_conditional_expr_1): Likewise.
	(build_new_op_1, build_new_method_call_1): Likewise.
	(build_op_call_1): Pass true to strict parameter.

From-SVN: r210435
parent 25109109
2014-05-14 Jason Merrill <jason@redhat.com>
* call.c (struct conversion_info): Rename 'from_type' to 'from'.
(arg_conversion_rejection, bad_arg_conversion_rejection)
(explicit_conversion_rejection, template_conversion_rejection): Adjust.
(add_function_candidate): Pass actual argument, rather than type, to
bad_arg_conversion_rejection.
(print_conversion_rejection): Explain what's wrong with the conversion.
(print_z_candidate): Say "candidate:" before each candidate.
(splice_viable): Be strict if we see a viable or template candidate.
(build_user_type_conversion_1): Pass false to strict parameter.
(perform_overload_resolution, build_conditional_expr_1): Likewise.
(build_new_op_1, build_new_method_call_1): Likewise.
(build_op_call_1): Pass true to strict parameter.
2014-05-13 Jason Merrill <jason@redhat.com>
* call.c (print_error_for_call_failure): Say "no match" rather
......
......@@ -458,9 +458,9 @@ enum rejection_reason_code {
struct conversion_info {
/* The index of the argument, 0-based. */
int n_arg;
/* The type of the actual argument. */
tree from_type;
/* The type of the formal argument. */
/* The actual argument or its type. */
tree from;
/* The type of the parameter. */
tree to_type;
};
......@@ -644,7 +644,7 @@ arg_conversion_rejection (tree first_arg, int n_arg, tree from, tree to)
struct rejection_reason *r = alloc_rejection (rr_arg_conversion);
int adjust = first_arg != NULL_TREE;
r->u.conversion.n_arg = n_arg - adjust;
r->u.conversion.from_type = from;
r->u.conversion.from = from;
r->u.conversion.to_type = to;
return r;
}
......@@ -655,7 +655,7 @@ bad_arg_conversion_rejection (tree first_arg, int n_arg, tree from, tree to)
struct rejection_reason *r = alloc_rejection (rr_bad_arg_conversion);
int adjust = first_arg != NULL_TREE;
r->u.bad_conversion.n_arg = n_arg - adjust;
r->u.bad_conversion.from_type = from;
r->u.bad_conversion.from = from;
r->u.bad_conversion.to_type = to;
return r;
}
......@@ -665,7 +665,7 @@ explicit_conversion_rejection (tree from, tree to)
{
struct rejection_reason *r = alloc_rejection (rr_explicit_conversion);
r->u.conversion.n_arg = 0;
r->u.conversion.from_type = from;
r->u.conversion.from = from;
r->u.conversion.to_type = to;
return r;
}
......@@ -675,7 +675,7 @@ template_conversion_rejection (tree from, tree to)
{
struct rejection_reason *r = alloc_rejection (rr_template_conversion);
r->u.conversion.n_arg = 0;
r->u.conversion.from_type = from;
r->u.conversion.from = from;
r->u.conversion.to_type = to;
return r;
}
......@@ -2072,7 +2072,7 @@ add_function_candidate (struct z_candidate **candidates,
if (t->bad_p)
{
viable = -1;
reason = bad_arg_conversion_rejection (first_arg, i, argtype, to_type);
reason = bad_arg_conversion_rejection (first_arg, i, arg, to_type);
}
}
......@@ -2161,7 +2161,7 @@ add_conv_candidate (struct z_candidate **candidates, tree fn, tree obj,
if (t->bad_p)
{
viable = -1;
reason = bad_arg_conversion_rejection (NULL_TREE, i, argtype, convert_type);
reason = bad_arg_conversion_rejection (NULL_TREE, i, arg, convert_type);
}
if (i == 0)
......@@ -2227,7 +2227,7 @@ build_builtin_candidate (struct z_candidate **candidates, tree fnname,
else if (t->bad_p)
{
viable = 0;
reason = bad_arg_conversion_rejection (NULL_TREE, i, argtypes[i],
reason = bad_arg_conversion_rejection (NULL_TREE, i, args[i],
types[i]);
}
convs[i] = t;
......@@ -3120,6 +3120,7 @@ splice_viable (struct z_candidate *cands,
struct z_candidate *viable;
struct z_candidate **last_viable;
struct z_candidate **cand;
bool found_strictly_viable = false;
/* Be strict inside templates, since build_over_call won't actually
do the conversions to get pedwarns. */
......@@ -3134,6 +3135,25 @@ splice_viable (struct z_candidate *cands,
while (*cand)
{
struct z_candidate *c = *cand;
if (!strict_p
&& (c->viable == 1 || TREE_CODE (c->fn) == TEMPLATE_DECL))
{
/* Be strict in the presence of a viable candidate. Also if
there are template candidates, so that we get deduction errors
for them instead of silently preferring a bad conversion. */
strict_p = true;
if (viable && !found_strictly_viable)
{
/* Put any spliced near matches back onto the main list so
that we see them if there is no strict match. */
*any_viable_p = false;
*last_viable = cands;
cands = viable;
viable = NULL;
last_viable = &viable;
}
}
if (strict_p ? c->viable == 1 : c->viable)
{
*last_viable = c;
......@@ -3141,6 +3161,8 @@ splice_viable (struct z_candidate *cands,
c->next = NULL;
last_viable = &c->next;
*any_viable_p = true;
if (c->viable == 1)
found_strictly_viable = true;
}
else
cand = &c->next;
......@@ -3195,18 +3217,37 @@ equal_functions (tree fn1, tree fn2)
static void
print_conversion_rejection (location_t loc, struct conversion_info *info)
{
tree from = info->from;
if (!TYPE_P (from))
from = lvalue_type (from);
if (info->n_arg == -1)
/* Conversion of implicit `this' argument failed. */
inform (loc, " no known conversion for implicit "
"%<this%> parameter from %qT to %qT",
info->from_type, info->to_type);
{
/* Conversion of implicit `this' argument failed. */
if (!TYPE_P (info->from))
/* A bad conversion for 'this' must be discarding cv-quals. */
inform (input_location, " passing %qT as %<this%> "
"argument discards qualifiers",
from);
else
inform (loc, " no known conversion for implicit "
"%<this%> parameter from %qT to %qT",
from, info->to_type);
}
else if (!TYPE_P (info->from))
{
if (info->n_arg >= 0)
inform (loc, " conversion of argument %d would be ill-formed:",
info->n_arg+1);
perform_implicit_conversion (info->to_type, info->from,
tf_warning_or_error);
}
else if (info->n_arg == -2)
/* Conversion of conversion function return value failed. */
inform (loc, " no known conversion from %qT to %qT",
info->from_type, info->to_type);
from, info->to_type);
else
inform (loc, " no known conversion for argument %d from %qT to %qT",
info->n_arg+1, info->from_type, info->to_type);
info->n_arg+1, from, info->to_type);
}
/* Print information about a candidate with WANT parameters and we found
......@@ -3281,13 +3322,13 @@ print_z_candidate (location_t loc, const char *msgstr,
case rr_explicit_conversion:
inform (cloc, " return type %qT of explicit conversion function "
"cannot be converted to %qT with a qualification "
"conversion", r->u.conversion.from_type,
"conversion", r->u.conversion.from,
r->u.conversion.to_type);
break;
case rr_template_conversion:
inform (cloc, " conversion from return type %qT of template "
"conversion function specialization to %qT is not an "
"exact match", r->u.conversion.from_type,
"exact match", r->u.conversion.from,
r->u.conversion.to_type);
break;
case rr_template_unification:
......@@ -3377,9 +3418,8 @@ print_z_candidates (location_t loc, struct z_candidate *candidates)
for (n_candidates = 0, cand1 = candidates; cand1; cand1 = cand1->next)
n_candidates++;
inform_n (loc, n_candidates, "candidate is:", "candidates are:");
for (; candidates; candidates = candidates->next)
print_z_candidate (loc, NULL, candidates);
print_z_candidate (loc, "candidate:", candidates);
}
/* USER_SEQ is a user-defined conversion sequence, beginning with a
......@@ -3663,7 +3703,7 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags,
}
}
candidates = splice_viable (candidates, pedantic, &any_viable_p);
candidates = splice_viable (candidates, false, &any_viable_p);
if (!any_viable_p)
{
if (args)
......@@ -3898,7 +3938,7 @@ perform_overload_resolution (tree fn,
LOOKUP_NORMAL,
candidates, complain);
*candidates = splice_viable (*candidates, pedantic, any_viable_p);
*candidates = splice_viable (*candidates, false, any_viable_p);
if (*any_viable_p)
cand = tourney (*candidates, complain);
else
......@@ -4209,7 +4249,9 @@ build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain)
}
}
candidates = splice_viable (candidates, pedantic, &any_viable_p);
/* Be strict here because if we choose a bad conversion candidate, the
errors we get won't mention the call context. */
candidates = splice_viable (candidates, true, &any_viable_p);
if (!any_viable_p)
{
if (complain & tf_error)
......@@ -4849,7 +4891,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3,
If the overload resolution fails, the program is
ill-formed. */
candidates = splice_viable (candidates, pedantic, &any_viable_p);
candidates = splice_viable (candidates, false, &any_viable_p);
if (!any_viable_p)
{
if (complain & tf_error)
......@@ -5373,7 +5415,7 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1,
break;
default:
strict_p = pedantic;
strict_p = false;
break;
}
......@@ -7851,7 +7893,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
access_binfo, flags, &candidates, complain);
}
any_viable_p = false;
candidates = splice_viable (candidates, pedantic, &any_viable_p);
candidates = splice_viable (candidates, false, &any_viable_p);
if (!any_viable_p)
{
......
......@@ -6,4 +6,3 @@ struct H {
};
int const& ref = H(); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 8 }
......@@ -7,5 +7,4 @@ class C
int fn (C c)
{
return C::operator float(c); // { dg-error "operator float.C" }
// { dg-message "candidate" "candidate note" { target *-*-* } 9 }
}
......@@ -15,6 +15,6 @@ struct B
void
foo (const B& b)
{
const A a = b; // { dg-error "conversion from 'const B' to non-scalar type 'const A' requested" }
const A a = b; // { dg-error "const B" }
}
......@@ -18,7 +18,6 @@ extern const vector signed short *cvssp;
void foo ()
{
vss = vld(i, vscp); /* { dg-error "no matching function for call" } */
// { dg-message "candidate" "candidate note" { target *-*-* } 20 }
vss = vld(i, vssp);
vss = vld(i, cvssp);
}
......
......@@ -14,7 +14,5 @@ int main()
{
A a;
a = B(); // { dg-error "no match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 16 }
a = 1.0; // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 18 }
}
......@@ -6,5 +6,4 @@ void f(int i, ...); // { dg-message "void f" }
int main()
{
f(1,1); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 8 }
}
......@@ -14,5 +14,4 @@ int main()
B b;
(A(b)); // OK
(A(b,1)); // { dg-error "no match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 16 }
}
......@@ -2,8 +2,8 @@
// PR c++/60755
// { dg-do compile { target c++11 } }
struct S {
void f(); // { dg-message "no known conversion for implicit 'this' parameter from 'const S\\*' to 'S\\*'" }
void f();
void g() const {
[=] { f(); } (); // { dg-error "no matching function for call to 'S::f\\(\\)'" }
[=] { f(); } (); // { dg-error "no match|qualifiers" }
}
};
......@@ -12,6 +12,5 @@ int main()
auto l = []() { return 5; }; // { dg-message "lambda closure type" }
run(l); // { dg-error "no match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 14 }
// { dg-error "use of deleted function" "candidate explanation" { target *-*-* } 5 }
}
......@@ -11,7 +11,5 @@ nullptr_t k( nullptr_t ); /* { dg-message "note" } */
void test_k()
{
k(0); /* { dg-error "is ambiguous" } */
// { dg-message "candidate" "candidate note" { target *-*-* } 13 }
k(__null); /* { dg-error "is ambiguous" } */
// { dg-message "candidate" "candidate note" { target *-*-* } 15 }
}
......@@ -8,5 +8,4 @@ template<typename... T> int foo(const T&) // { dg-error "not expanded with|T" }
void bar()
{
foo(0); // { dg-error "no matching" }
// { dg-message "(candidate|cannot convert)" "candidate note" { target *-*-* } 10 }
}
......@@ -7,4 +7,3 @@ template <typename... T> struct A // { dg-message "candidates|A" }
};
A<int> a(0); // { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 9 }
......@@ -37,13 +37,13 @@ int test1_1()
const A ca = a; // { dg-error "deleted" }
volatile A va;
const volatile A cva = a; // { dg-error "deleted" }
sink_1_1(ca); // { dg-error "invalid initialization" }
sink_1_1(va); // { dg-error "invalid initialization" }
sink_1_1(cva); // { dg-error "invalid initialization" }
sink_1_1(source()); // { dg-error "invalid initialization" }
sink_1_1(c_source()); // { dg-error "invalid initialization" }
sink_1_1(v_source()); // { dg-error "invalid initialization" }
sink_1_1(cv_source()); // { dg-error "invalid initialization" }
sink_1_1(ca); // { dg-error "" }
sink_1_1(va); // { dg-error "" }
sink_1_1(cva); // { dg-error "" }
sink_1_1(source()); // { dg-error "" }
sink_1_1(c_source()); // { dg-error "" }
sink_1_1(v_source()); // { dg-error "" }
sink_1_1(cv_source()); // { dg-error "" }
return 0;
}
......@@ -55,10 +55,10 @@ int test1_2()
const A ca = a; // { dg-error "deleted" }
volatile A va;
const volatile A cva = a; // { dg-error "deleted" }
sink_1_2(va); // { dg-error "invalid initialization" }
sink_1_2(cva); // { dg-error "invalid initialization" }
sink_1_2(v_source()); // { dg-error "invalid initialization" }
sink_1_2(cv_source()); // { dg-error "invalid initialization" }
sink_1_2(va); // { dg-error "" }
sink_1_2(cva); // { dg-error "" }
sink_1_2(v_source()); // { dg-error "" }
sink_1_2(cv_source()); // { dg-error "" }
return 0;
}
......@@ -70,12 +70,12 @@ int test1_3()
const A ca = a; // { dg-error "deleted" }
volatile A va;
const volatile A cva = a; // { dg-error "deleted" }
sink_1_3(ca); // { dg-error "invalid initialization" }
sink_1_3(cva); // { dg-error "invalid initialization" }
sink_1_3(source()); // { dg-error "invalid initialization" }
sink_1_3(c_source()); // { dg-error "invalid initialization" }
sink_1_3(v_source()); // { dg-error "invalid initialization" }
sink_1_3(cv_source()); // { dg-error "invalid initialization" }
sink_1_3(ca); // { dg-error "" }
sink_1_3(cva); // { dg-error "" }
sink_1_3(source()); // { dg-error "" }
sink_1_3(c_source()); // { dg-error "" }
sink_1_3(v_source()); // { dg-error "" }
sink_1_3(cv_source()); // { dg-error "" }
return 0;
}
......@@ -87,10 +87,10 @@ int test1_4()
const A ca = a; // { dg-error "deleted" }
volatile A va;
const volatile A cva = a; // { dg-error "deleted" }
sink_1_4(source()); // { dg-error "invalid initialization" }
sink_1_4(c_source()); // { dg-error "invalid initialization" }
sink_1_4(v_source()); // { dg-error "invalid initialization" }
sink_1_4(cv_source()); // { dg-error "invalid initialization" }
sink_1_4(source()); // { dg-error "" }
sink_1_4(c_source()); // { dg-error "" }
sink_1_4(v_source()); // { dg-error "" }
sink_1_4(cv_source()); // { dg-error "" }
return 0;
}
......@@ -103,12 +103,12 @@ int test1_5()
volatile A va;
const volatile A cva = a; // { dg-error "deleted" }
sink_1_5(a); // { dg-error "lvalue" }
sink_1_5(ca); // { dg-error "invalid initialization" }
sink_1_5(va); // { dg-error "invalid initialization" }
sink_1_5(cva); // { dg-error "invalid initialization" }
sink_1_5(c_source()); // { dg-error "invalid initialization" }
sink_1_5(v_source()); // { dg-error "invalid initialization" }
sink_1_5(cv_source()); // { dg-error "invalid initialization" }
sink_1_5(ca); // { dg-error "" }
sink_1_5(va); // { dg-error "" }
sink_1_5(cva); // { dg-error "" }
sink_1_5(c_source()); // { dg-error "" }
sink_1_5(v_source()); // { dg-error "" }
sink_1_5(cv_source()); // { dg-error "" }
return 0;
}
......@@ -122,10 +122,10 @@ int test1_6()
const volatile A cva = a; // { dg-error "deleted" }
sink_1_6(a); // { dg-error "lvalue" }
sink_1_6(ca); // { dg-error "lvalue" }
sink_1_6(va); // { dg-error "invalid initialization" }
sink_1_6(cva); // { dg-error "invalid initialization" }
sink_1_6(v_source()); // { dg-error "invalid initialization" }
sink_1_6(cv_source()); // { dg-error "invalid initialization" }
sink_1_6(va); // { dg-error "" }
sink_1_6(cva); // { dg-error "" }
sink_1_6(v_source()); // { dg-error "" }
sink_1_6(cv_source()); // { dg-error "" }
return 0;
}
......@@ -138,11 +138,11 @@ int test1_7()
volatile A va;
const volatile A cva = a; // { dg-error "deleted" }
sink_1_7(a); // { dg-error "lvalue" }
sink_1_7(ca); // { dg-error "invalid initialization" }
sink_1_7(ca); // { dg-error "" }
sink_1_7(va); // { dg-error "lvalue" }
sink_1_7(cva); // { dg-error "invalid initialization" }
sink_1_7(c_source()); // { dg-error "invalid initialization" }
sink_1_7(cv_source()); // { dg-error "invalid initialization" }
sink_1_7(cva); // { dg-error "" }
sink_1_7(c_source()); // { dg-error "" }
sink_1_7(cv_source()); // { dg-error "" }
return 0;
}
......
......@@ -31,12 +31,12 @@ const volatile A cv_source();
// 7 at a time
one sink_7_1234567( A&); // { dg-message "one sink_7_1234567|no known conversion" }
two sink_7_1234567(const A&); // { dg-message "note" }
three sink_7_1234567(volatile A&); // { dg-message "note" }
four sink_7_1234567(const volatile A&); // { dg-message "note" }
five sink_7_1234567( A&&); // { dg-message "note" }
six sink_7_1234567(const A&&); // { dg-message "note" }
seven sink_7_1234567(volatile A&&); // { dg-message "note" }
two sink_7_1234567(const A&);
three sink_7_1234567(volatile A&);
four sink_7_1234567(const volatile A&);
five sink_7_1234567( A&&);
six sink_7_1234567(const A&&);
seven sink_7_1234567(volatile A&&);
int test7_1234567()
{
......@@ -44,8 +44,7 @@ int test7_1234567()
const A ca = a; // { dg-error "deleted" }
volatile A va;
const volatile A cva = a; // { dg-error "deleted" }
sink_7_1234567(cv_source()); // { dg-error "no match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 47 }
sink_7_1234567(cv_source()); // { dg-error "" }
return 0;
}
......@@ -63,17 +62,17 @@ int test7_1235678()
const A ca = a; // { dg-error "deleted" }
volatile A va;
const volatile A cva = a; // { dg-error "deleted" }
sink_7_1235678(cva); // { dg-error "lvalue" }
sink_7_1235678(cva); // { dg-error "" }
return 0;
}
two sink_7_2345678(const A&); // { dg-message "note" }
three sink_7_2345678(volatile A&); // { dg-message "note" }
four sink_7_2345678(const volatile A&); // { dg-message "note" }
five sink_7_2345678( A&&); // { dg-message "note" }
six sink_7_2345678(const A&&); // { dg-message "note" }
seven sink_7_2345678(volatile A&&); // { dg-message "note" }
eight sink_7_2345678(const volatile A&&); // { dg-message "note" }
two sink_7_2345678(const A&);
three sink_7_2345678(volatile A&);
four sink_7_2345678(const volatile A&);
five sink_7_2345678( A&&);
six sink_7_2345678(const A&&);
seven sink_7_2345678(volatile A&&);
eight sink_7_2345678(const volatile A&&);
int test7_2345678()
{
......@@ -81,18 +80,17 @@ int test7_2345678()
const A ca = a; // { dg-error "deleted" }
volatile A va;
const volatile A cva = a; // { dg-error "deleted" }
sink_7_2345678(a); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 84 }
sink_7_2345678(a); // { dg-error "" }
return 0;
}
one sink_7_1234678( A&);
two sink_7_1234678(const A&); // { dg-message "note" }
two sink_7_1234678(const A&);
three sink_7_1234678(volatile A&);
four sink_7_1234678(const volatile A&);
six sink_7_1234678(const A&&); // { dg-message "note" }
seven sink_7_1234678(volatile A&&); // { dg-message "note" }
eight sink_7_1234678(const volatile A&&); // { dg-message "note" }
six sink_7_1234678(const A&&);
seven sink_7_1234678(volatile A&&);
eight sink_7_1234678(const volatile A&&);
int test7_1234678()
{
......@@ -100,8 +98,7 @@ int test7_1234678()
const A ca = a; // { dg-error "deleted" }
volatile A va;
const volatile A cva = a; // { dg-error "deleted" }
sink_7_1234678(source()); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 103 }
sink_7_1234678(source()); // { dg-error "" }
return 0;
}
......
......@@ -9,7 +9,6 @@ template<typename... Args>
void g(Args&&... args)
{
f(forward<Args...>(args...)); // { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 11 }
}
void h()
......
......@@ -6,7 +6,5 @@ struct A { // { dg-message "A" }
void foo(volatile A a) {
1 ? a : 0; // { dg-error "match|temporary" }
// { dg-message "candidate" "candidate note" { target *-*-* } 8 }
1 ? 0 : a; // { dg-error "match|temporary" }
// { dg-message "candidate" "candidate note" { target *-*-* } 10 }
}
......@@ -15,6 +15,5 @@ struct A
void (A::*p)() = &A::f;
void (A::*q)() = &(A::f); // { dg-error "parenthesized" "" }
foo(&g<int>); // { dg-error "no matching" "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 17 }
}
};
......@@ -11,6 +11,5 @@ foo ()
{
A a(0);
#pragma omp parallel private (a) // { dg-error "no matching function" }
// { dg-message "candidate" "candidate note" { target *-*-* } 13 }
;
}
......@@ -12,6 +12,5 @@ foo ()
{
A a(6);
#pragma omp parallel private (a) // { dg-error "call of overloaded" }
// { dg-message "candidate" "candidate note" { target *-*-* } 14 }
;
}
......@@ -6,7 +6,6 @@ struct G {
};
class A // { dg-error "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 8 }
{
const G g;
};
......
......@@ -22,6 +22,5 @@ struct B : A1, A2
int Foo (B const &b)
{
return b; // { dg-error "ambiguous" "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 24 }
}
......@@ -6,7 +6,6 @@ int main() {
int i;
void* operator new(__SIZE_TYPE__ s, int* p);
int* e = new(&i) int; // { dg-error "no matching function" }
// { dg-message "candidate" "candidate note" { target *-*-* } 8 }
int* f = new int;
return 0;
}
......
......@@ -20,7 +20,6 @@ void h()
using C::f;
f('h');
f(1); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 22 }
void f(int); // { dg-error "previous declaration" }
}
......
......@@ -7,6 +7,5 @@ struct A // { dg-message "note" }
};
struct B : A {}; // { dg-error "no matching function for call|deleted" }
// { dg-message "candidate" "candidate note" { target *-*-* } 9 }
B b; // { dg-message "synthesized method|deleted" }
......@@ -9,5 +9,4 @@ struct A // { dg-message "operator=|no known conversion" }
void bar (A& a)
{
a.foo () = 0; // { dg-error "operand types are 'A' and 'int'" }
// { dg-message "candidate" "candidate note" { target *-*-* } 11 }
}
......@@ -10,5 +10,4 @@ foo ()
{
A a;
a = ({ { 1; } }); // { dg-error "no match for" }
// { dg-message "candidate" "candidate note" { target *-*-* } 12 }
}
......@@ -6,5 +6,4 @@ template<int> void foo(struct {}*); // { dg-message "" }
void bar()
{
foo<0>(0); // { dg-error "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 8 }
}
......@@ -20,5 +20,4 @@ void f(B); // { dg-message "note" "candidate" }
int main()
{
f (42); // { dg-error "ambiguous" "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 22 }
}
......@@ -19,5 +19,4 @@ void foo(B); // { dg-message "initializing" }
void bar()
{
foo(0); // { dg-error "no matching function" "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 21 }
}
......@@ -14,5 +14,4 @@ int main ()
A a;
a + a; // { dg-error "ambiguous" "ambiguous" }
// { dg-message "operator" "match candidate text" { target *-*-* } 15 }
// { dg-message "candidates" "candidates" { target *-*-* } 15 }
}
......@@ -17,5 +17,4 @@ B
f (B const& b)
{
return b; // { dg-error "matching" "matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 19 }
}
......@@ -16,6 +16,5 @@ void f(X *x = new X[4]); // { dg-error "" }
void f(X *x = new (3) X(6)); // { dg-error "" }
void f(X *x = new (2) X[10]); // { dg-error "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 18 }
void f(X *x = new X[10][5]); // { dg-error "" }
......@@ -16,9 +16,6 @@ void
test ()
{
foo <0> (0); // { dg-error "is ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 18 }
bar <1> (0, 1); // { dg-error "is ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 20 }
baz (0); // { dg-error "is ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 22 }
}
......@@ -73,12 +73,10 @@ int main () {
exit (0);
_exit (0); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 75 }
abort ();
c1 ();
C1 (); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 80 }
c2 ();
C2 (); // one might expect an ambiguous call error here as well, but
......@@ -86,7 +84,6 @@ int main () {
c3 ();
C3 (); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 88 }
C3 (0);
C3 (0l);
}
......@@ -8,8 +8,6 @@ class QString { }; // { dg-error "redefinition" }
const QString q () {
QString z; // { dg-error "matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 10 }
int x;
return x ? QString () : QString (); // { dg-error "matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 13 }
}
// { dg-options "-fshow-column -fmessage-length=0 -ansi -pedantic-errors -Wno-long-long " }
// PR C++/17867
struct A // { dg-message "8:operator=|no known conversion for implicit" }
struct A // { dg-message "8:operator=" }
{
A(int);
};
......@@ -10,6 +10,5 @@ const A& foo();
void bar()
{
foo()=A(0); // { dg-error "8:no match for 'operator='" }
// { dg-message "candidate" "candidate note" { target *-*-* } 13 }
foo()=A(0); // { dg-error "8:no match|const" }
}
......@@ -7,6 +7,5 @@ struct der : public virtual virt { // { dg-message "8:der::der|candidate expects
};
struct top : public der {
top () {} // { dg-bogus "der\\(const" }
// { dg-message "candidate" "candidate note" { target *-*-* } 9 }
};
// { dg-error "10:no matching function for call to 'der" "" { target *-*-* } 9 }
......@@ -12,7 +12,6 @@ namespace N1 {
{
X x;
f(x); // { dg-error "matching" "matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 14 }
}
}
......@@ -31,7 +30,6 @@ namespace N2 {
{
X<T> x;
N2::f(x); // { dg-error "matching" "matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 33 }
}
template int foo<float>(); // { dg-message "required from here" }
......
......@@ -11,5 +11,4 @@ struct A
};
A a = 0; // { dg-error "no matching function" }
// { dg-message "candidate" "candidate note" { target *-*-* } 13 }
......@@ -14,7 +14,5 @@ template<typename FP_> struct Vec { // { dg-message "note" }
}
};
Vec<double> v(3,4,12); // { dg-error "no matching" }
// { dg-message "note" "note" { target *-*-* } 16 }
Vec<double> V(12,4,3); // { dg-error "no matching" }
// { dg-message "note" "note" { target *-*-* } 18 }
Vec<double> c = v^V; // { dg-message "required" }
......@@ -53,7 +53,7 @@ struct foo {
bindb (&barf);
bindb (&foo::barf); // { dg-error "ambiguous" }
// { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 55 }
bind (&bark); // { dg-error "no matching function" }
// { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 58 }
......@@ -69,7 +69,7 @@ struct foo {
bindb (&bark);
bindb (&bar::bark); // { dg-error "ambiguous" }
// { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 71 }
}
};
......@@ -105,7 +105,7 @@ struct foo {
bindb (&barf);
bindb (&foo::barf); // { dg-error "ambiguous" }
// { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 107 }
bind (&bark); // { dg-error "no matching function" }
// { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 110 }
......@@ -121,7 +121,7 @@ struct foo {
bindb (&bark);
bindb (&barT::bark); // { dg-error "ambiguous" }
// { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 123 }
}
};
......
......@@ -32,12 +32,8 @@ int main()
{
A<B> a;
a.f(); // { dg-error "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 34 }
a.g(); // { dg-error "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 36 }
f(i); // { dg-error "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 39 }
f(p); // { dg-error "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 41 }
}
......@@ -26,7 +26,5 @@ struct B
int main()
{
f(1); // { dg-error "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 28 }
B<A<int> >().f(); // { dg-error "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 30 }
}
......@@ -8,4 +8,4 @@ void bar()
{
foo(A<0>(), A<1>()); // { dg-error "no matching" }
}
// { dg-message "candidate|parameter 'N' ('0' and '1')" "" { target *-*-* } 9 }
// { dg-message "deduced conflicting values" "" { target *-*-* } 9 }
......@@ -6,4 +6,4 @@ void bar(void* p)
{
foo(0, p); // { dg-error "no matching" }
}
// { dg-message "candidate|parameter 'T' ('int' and 'void*')" "" { target *-*-* } 7 }
// { dg-message "parameter 'T' .'int' and 'void.'" "" { target *-*-* } 7 }
......@@ -10,5 +10,4 @@ A a; // { dg-error "incomplete type" }
void bar()
{
foo<a>(); // { dg-error "(no matching function|could not convert)" }
// { dg-message "candidate" "candidate note" { target *-*-* } 12 }
}
......@@ -19,7 +19,6 @@ struct B
template <typename T> struct C
{
virtual void bar() const { T::foo(); } // { dg-error "no matching function" }
// { dg-message "candidate" "candidate note" { target *-*-* } 21 }
};
C<B> c; // { dg-message "required" }
......@@ -6,5 +6,4 @@ template <typename T> void foo() {} // { dg-message "note" }
int main () {
struct S {};
foo<S> (); // { dg-error "(match|template argument for|trying to instantiate)" }
// { dg-message "candidate" "candidate note" { target *-*-* } 8 }
}
......@@ -6,7 +6,6 @@ struct C
void f() {
int* node;
new (&node) int(0); // { dg-error "new" }
// { dg-message "candidate" "candidate note" { target *-*-* } 8 }
}
};
......
......@@ -5,6 +5,5 @@ template<operator+> void foo(); // { dg-error "before|non-function|template" }
void bar()
{
foo(); // { dg-error "no matching function" }
// { dg-message "(candidate|deduce template parameter)" "candidate note" { target *-*-* } 7 }
}
......@@ -12,5 +12,4 @@ template <typename T> T A::* Foo (); // { dg-error "reference" }
void Baz ()
{
Foo <int &> (); // { dg-error "no matching function" "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 14 }
}
......@@ -13,5 +13,4 @@ template<void (A::*)()> void bar(); // { dg-message "note" }
void baz()
{
bar<&B::foo>(); // { dg-error "not a valid template argument|no match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 15 }
}
......@@ -11,7 +11,6 @@ template <template <class> class TT> void f()
{
TT<int> y;
y = 0; // { dg-error "no match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 13 }
}
template <class T> struct C
......
......@@ -13,6 +13,5 @@ template<int I> void fn (char (*) [cl<I>::value] = 0 ); // { dg-error "zero-size
void foo (void)
{
fn<0> (); // { dg-error "no matching function" }
// { dg-message "candidate" "candidate note" { target *-*-* } 15 }
}
......@@ -16,6 +16,6 @@ template <typename T> struct srp
};
ptr<int> parent_get()
{
srp<int> parent; // { dg-message "candidate" }
srp<int> parent;
return parent; // { dg-error "is ambiguous" }
}
......@@ -20,7 +20,6 @@ struct Bar
Foo Quux (Bar const &b)
{
return b; // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 22 }
}
......@@ -6,5 +6,4 @@ template<typedef> void foo(); // { dg-error "no type|typedef declaration|templa
void bar()
{
foo<int>(); // { dg-error "matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 8 }
}
......@@ -24,7 +24,6 @@ enum { first, last};
void foo(void) {
sanjose obj(first); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 26 }
}
......@@ -13,6 +13,5 @@ extern panama dig();
void foo() {
panama obj;
obj = dig(); // { dg-error "no match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 15 }
}
......@@ -14,5 +14,4 @@ void myfunc (const B& t0); // { dg-message "note" }
int main ()
{
myfunc(1); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 16 }
}
......@@ -15,6 +15,5 @@ int
main()
{
new GlobalAddress(Value()); // internal error occured here// { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 17 }
//new GlobalAddress(new Value()); // This line is correct code
}
......@@ -13,12 +13,10 @@ class bug { // { dg-message "bug::bug|candidate expects" }
bug::bug(int size) // { dg-message "bug::bug|candidate expects" }
{
numbers = new internal(size * size);// { dg-error "no match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 15 }
}
int
main()
{
bug test; // { dg-error "no match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 22 }
}
......@@ -45,5 +45,4 @@ void
foo (bar yylval, bar *yyvsp)
{
nnyacc::assign(yylval.valueList, yyvsp[0].valueList);// { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 47 }
}
......@@ -17,6 +17,5 @@ int main ()
Bar b;
b.f ();// { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 19 }
b.f (10);
}
......@@ -18,7 +18,6 @@
B::WantsNew ( (NewObject) A::NewOne );
// This used to die in convert_harshness_{ansi,old} cuz it
// didn't know what to do about a void type.
B::WantsNew ( A::NewOne );// { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 21 }
B::WantsNew ( A::NewOne );// { dg-error "no matching|conversion" }
}
};
// { dg-do assemble }
// GROUPS passed overloading
class CLogger // { dg-message "candidate" }
class CLogger
{
public:
void operator() (int,const char *) {}; // { dg-message "note" }
void operator() (int,const char *, ...) {}; // { dg-message "note" }
} Log;
class CGLogger : public CLogger // { dg-message "candidate" }
class CGLogger : public CLogger
{
} GLog;
......
......@@ -21,7 +21,6 @@ void bar (f_ptr_t2); // { dg-message "note" }
void function ()
{
bar (foo); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 23 }
}
int main () { return 0; }
......@@ -24,7 +24,6 @@ struct0::struct0 (int, void *) // { dg-message "note" }
}
struct struct0_derived_struct_0 : public struct0 { // { dg-error "no matching|deleted" }
// { dg-message "candidate" "candidate note" { target *-*-* } 26 }
};
struct0_derived_struct_0 object; // { dg-message "synthesized|deleted" }
......
......@@ -25,7 +25,6 @@ struct D : public B {
void h(D* pd)
{
pd->f(1); // { dg-error "no matching" } D::f(struct B) hides B::f(int)
// { dg-message "candidate" "candidate note" { target *-*-* } 27 }
}
int main () { return 0; }
......@@ -23,7 +23,6 @@ char c;
void test ()
{
function0 (c,c); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 25 }
}
int main () { return 0; }
......@@ -29,7 +29,7 @@ struct t_0_st_0 {
operator t_0_st_1 ();// { dg-message "note" }
};
t_0_st_0 t_0_st_0_obj0; // { dg-message "candidate" }
t_0_st_0 t_0_st_0_obj0;
void t_0_assignment ()
{
......@@ -63,7 +63,7 @@ struct t_1_st_0 {
operator t_1_st_1 (); // { dg-message "note" }
};
t_1_st_0 t_1_st_0_obj0; // { dg-message "candidate" }
t_1_st_0 t_1_st_0_obj0;
void t_1_assignment ()
{
......@@ -72,9 +72,7 @@ void t_1_assignment ()
t_1_st_1 t_1_st_1_obj2;
t_1_st_1_obj0 = t_1_st_0_obj0; // { dg-error "no match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 74 }
t_1_st_1_obj1 = t_1_st_1 (t_1_st_0_obj0); // { dg-error "no match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 76 }
}
void t_1_local_init ()
......@@ -98,7 +96,7 @@ struct t_2_st_0 {
operator t_2_st_1 (); // { dg-message "note" }
};
t_2_st_0 t_2_st_0_obj0; // { dg-message "candidate" }
t_2_st_0 t_2_st_0_obj0;
void t_2_assignment ()
{
......
......@@ -11,7 +11,6 @@ main ()
try
{
throw A(); // { dg-error "no matching" "match" } can't copy
// { dg-message "candidate" "candidate note" { target *-*-* } 13 }
// { dg-error "thrown expression" "expr" { target *-*-* } 13 }
}
catch (...) { }
......
......@@ -23,7 +23,5 @@ void foo(Something* pX)
{
DoSomething(1); // { dg-error "could not convert" }
pX->DoSomething(1); // { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 25 }
(*pX).DoSomething(1); // { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 27 }
}
......@@ -10,5 +10,4 @@ struct Node // { dg-message "note" }
void bug(int i)
{
Node* q = new Node(i); // { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 12 }
}
......@@ -4,5 +4,4 @@ void f (long); // { dg-message "note" }
int main()
{
f (1 & 0xffffff00UL); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 6 }
}
......@@ -9,5 +9,4 @@ struct Foo {
int main()
{
Foo* f1 = new Foo(); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 11 }
}
......@@ -10,7 +10,6 @@ struct B : public A {
void h () {
extern void g (); // { dg-message "" }
f("foo"); // { dg-error "" } hidden
// { dg-message "candidate" "candidate note" { target *-*-* } 12 }
g("foo"); // { dg-error "" } hidden
}
};
......@@ -11,5 +11,4 @@ int func(T, U) // { dg-message "note" }
int main ()
{
func (0, 1); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 13 }
}
......@@ -13,7 +13,5 @@ X foo() { X x; return x; }
int main()
{
X x(foo()); // { dg-error "no match" } Compiler doesn't warn about temporary reference.
// { dg-message "candidate" "candidate note" { target *-*-* } 15 }
x.bar(foo()); // { dg-error "no match" } The same mistake is warned about in this case.
// { dg-message "candidate" "candidate note" { target *-*-* } 17 }
}
......@@ -25,8 +25,6 @@ int main()
B b;
a.f(0);// { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 27 }
b.f(0);// { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 29 }
}
......@@ -18,6 +18,5 @@ foo(S *o)
{ // Neither call has a usable constructor for conversions of char[5] to Ack.
function("adsf");// { dg-error "could not convert" }
o->method("adsf");// { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 20 }
return 0;
}
......@@ -24,7 +24,6 @@ void B::set (f2 f) { std::cout << "called B\n|no known conversion";} // { dg-mes
int main() {
B b;
b.set(F1); // ARM page 309: should call A.set(f1) and that what g++ does,// { dg-error "match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 26 }
// but 13.1 of ARM clearly states that it should call B::set()
// or generate an error because overloading works only for
// functions within the same scope (first page of chapter 13)
......
......@@ -18,5 +18,4 @@ public:
int main()
{
B(10);// { dg-error "match" } B doesn't have a constructor taking int
// { dg-message "candidate" "candidate note" { target *-*-* } 20 }
}
......@@ -20,5 +20,4 @@ int main()
X *y = new X(10, "123");
// the compiler must reject this constructor call:
X *x = new X("abc");// { dg-error "match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 22 }
}
......@@ -31,7 +31,6 @@ X::X( int xi ) // { dg-error "14:return type specification for constructor inval
const X X::x0( 0 );
Y::Y() // { dg-error "6:no matching function for call to 'X::X\\(\\)'" }
// { dg-message "candidate" "candidate note" { target *-*-* } 33 }
{
xx = X::x0;
}
......@@ -33,7 +33,6 @@ int blort(Foo& f)
int main()
{
var_Foo b(2);// { dg-error "match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 35 }
b->a = 0;
int x = blort(b);
return x;
......
......@@ -24,7 +24,6 @@ int main()
Enum e = enumerator1;
Struct s;
int x = funct(e+1);// { dg-error "invalid" }
int y = s.getI(e+1);// { dg-error "match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 27 }
int y = s.getI(e+1);// { dg-error "match|conv" }
return x+y;
}
......@@ -32,6 +32,5 @@ static void foo(int i, int j, double x, double y) {
std::cout << "Max(int): " << max(i,j) << " Max(double): " <<
max(x,y) << '\n';
std::cout << "Max(int, double): " << max(i, y) << '\n';// { dg-error "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 34 }
}
......@@ -17,5 +17,4 @@ void
test(B &b1, const B &b2)
{
b1 = b2;// { dg-error "match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 19 }
}
......@@ -11,4 +11,3 @@ class A { // { dg-message "note" } copy ctor candidate
};
A a(0); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 13 }
......@@ -10,6 +10,5 @@ class Child : public Parent { // { dg-message "note" } called
int main() {
Child c( "String initializer" ); // { dg-error "match" } bad
// { dg-message "candidate" "candidate note" { target *-*-* } 12 }
return 0;
}
......@@ -197,7 +197,6 @@ List_DLS<T>::search(const T& item) const
{
for (Pix x=this->first(); 0 != x; this->next(x)) {
if (item == this->operator()(x)) // { dg-error "match" } const subversion
// { dg-message "candidate" "candidate note" { target *-*-* } 199 }
return x;
}
return 0;
......
......@@ -19,6 +19,5 @@ class C
{
B b;
A a = b;// { dg-error "match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 21 }
}
};
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