Commit fa76f2c6 by Jonathan Wakely Committed by Jonathan Wakely

Harmonize diagnostics for invalid reference binding

gcc/cp:

	* call.c (convert_like_real): Harmonize diagnostics for invalid
	reference binding.

gcc/testsuite:

	* call.c (convert_like_real): Harmonize diagnostics for invalid
	reference binding.
	* g++.dg/conversion/pr16333.C: Adjust dg-error regexp.
	* g++.dg/conversion/pr41426.C: Likewise.
	* g++.dg/conversion/pr66211.C: Likewise.
	* g++.dg/cpp1y/lambda-init9.C: Likewise.
	* g++.dg/init/ref8.C: Likewise.
	* g++.old-deja/g++.law/cvt20.C: Likewise.
	* g++.old-deja/g++.mike/p9732c.C: Likewise.

From-SVN: r239184
parent 3e9f67e6
2016-08-06 Jonathan Wakely <jwakely@redhat.com>
* call.c (convert_like_real): Harmonize diagnostics for invalid
reference binding.
2016-08-05 Martin Sebor <msebor@redhat.com>
* constexpr.c (cxx_eval_store_expression): Remove hyphen from
......
......@@ -6710,15 +6710,15 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
tree extype = TREE_TYPE (expr);
if (TYPE_REF_IS_RVALUE (ref_type)
&& lvalue_p (expr))
error_at (loc, "cannot bind %qT lvalue to %qT",
extype, totype);
error_at (loc, "cannot bind rvalue reference of type %qT to "
"lvalue of type %qT", totype, extype);
else if (!TYPE_REF_IS_RVALUE (ref_type) && !lvalue_p (expr)
&& !CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (ref_type)))
error_at (loc, "invalid initialization of non-const reference of "
"type %qT from an rvalue of type %qT", totype, extype);
error_at (loc, "cannot bind non-const lvalue reference of "
"type %qT to an rvalue of type %qT", totype, extype);
else if (!reference_compatible_p (TREE_TYPE (totype), extype))
error_at (loc, "binding %qT to reference of type %qT "
"discards qualifiers", extype, totype);
error_at (loc, "binding reference of type %qT to %qT "
"discards qualifiers", totype, extype);
else
gcc_unreachable ();
maybe_print_user_conv_context (convs);
......
2016-08-06 Jonathan Wakely <jwakely@redhat.com>
* g++.dg/conversion/pr16333.C: Adjust dg-error regexp.
* g++.dg/conversion/pr41426.C: Likewise.
* g++.dg/conversion/pr66211.C: Likewise.
* g++.dg/cpp1y/lambda-init9.C: Likewise.
* g++.dg/init/ref8.C: Likewise.
* g++.old-deja/g++.law/cvt20.C: Likewise.
* g++.old-deja/g++.mike/p9732c.C: Likewise.
2016-08-05 Patrick Palka <ppalka@gcc.gnu.org>
PR tree-optimization/18046
......
......@@ -7,4 +7,4 @@ struct X {
int a[3];
X foo1 () { return a; }
const X &foo2 () { return a; } // { dg-warning "returning reference to temporary" }
X &foo3 () { return a; } // { dg-error "invalid initialization" }
X &foo3 () { return a; } // { dg-error "cannot bind non-const lvalue ref" }
......@@ -23,7 +23,7 @@ const A<float> &g3()
A<float> &g4()
{
float f[] = {1.1f, 2.3f};
return f; // { dg-error "invalid initialization" }
return f; // { dg-error "cannot bind non-const lvalue ref" }
}
struct B
......
......@@ -7,5 +7,5 @@ int main()
{
int x = 0;
double y = 1;
f(1 > 0 ? x : y); // { dg-error "from an rvalue" }
f(1 > 0 ? x : y); // { dg-error "cannot bind .* to an rvalue" }
}
......@@ -2,5 +2,5 @@
void f()
{
[&x=1]{}; // { dg-error "cannot capture|invalid initialization" }
[&x=1]{}; // { dg-error "cannot capture|cannot bind non-const lvalue ref" }
}
......@@ -6,5 +6,5 @@ A operator*(A, A);
A& operator+=(A& a, const A& b)
{
return a = a * b; // { dg-error "non-const reference" }
return a = a * b; // { dg-error "non-const lvalue reference" }
}
......@@ -16,5 +16,5 @@ void f(const char *& x) // { dg-message "argument" }
int main()
{
f ("foo"); // { dg-error "invalid initialization" }
f ("foo"); // { dg-error "cannot bind non-const lvalue reference" }
}
......@@ -2,4 +2,4 @@
// prms-id: 9732
struct foo {};
foo& x() { return foo(); } // { dg-error "invalid init" }
foo& x() { return foo(); } // { dg-error "cannot bind non-const lvalue" }
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