re PR c++/5293 (confusing message when binding a temporary to a reference)
PR c++/5293 * call.c (initialize_reference): Improve diagnostic. From-SVN: r69332
This commit is contained in:
parent
c573d965f9
commit
f19319dbdf
|
@ -1,3 +1,8 @@
|
|||
2003-07-14 Gabriel Dos Reis <gdr@integrable-solutions.net>
|
||||
|
||||
PR c++/5293
|
||||
* call.c (initialize_reference): Improve diagnostic.
|
||||
|
||||
2003-07-14 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
|
||||
|
||||
PR c++/11154
|
||||
|
|
|
@ -6035,7 +6035,13 @@ initialize_reference (tree type, tree expr, tree decl)
|
|||
conv = reference_binding (type, TREE_TYPE (expr), expr, LOOKUP_NORMAL);
|
||||
if (!conv || ICS_BAD_FLAG (conv))
|
||||
{
|
||||
error ("could not convert `%E' to `%T'", expr, type);
|
||||
if (!(TYPE_QUALS (TREE_TYPE (type)) & TYPE_QUAL_CONST)
|
||||
&& !real_lvalue_p (expr))
|
||||
error ("invalid initialization of non-const reference of "
|
||||
"type '%T' from a temporary of type '%T'",
|
||||
type, TREE_TYPE (expr));
|
||||
else
|
||||
error ("could not convert `%E' to `%T'", expr, type);
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
struct A {
|
||||
A operator=(const A&);
|
||||
};
|
||||
|
||||
A operator*(A, A);
|
||||
|
||||
A& operator+=(A& a, const A& b)
|
||||
{
|
||||
return a = a * b; // { dg-error "non-const reference" }
|
||||
}
|
Loading…
Reference in New Issue