[cfe-commits] r123953 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaInit.cpp test/SemaCXX/rval-references.cpp
Douglas Gregor
dgregor at apple.com
Thu Jan 20 17:04:33 PST 2011
Author: dgregor
Date: Thu Jan 20 19:04:33 2011
New Revision: 123953
URL: http://llvm.org/viewvc/llvm-project?rev=123953&view=rev
Log:
Improve the diagnostic that complains about binding an rvalue
reference to an lvalue.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/rval-references.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=123953&r1=123952&r2=123953&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 20 19:04:33 2011
@@ -767,7 +767,8 @@
"base class|a vector element}0 of type %1 with an %select{rvalue|lvalue}2 of "
"type %3">;
-def err_lvalue_to_rvalue_ref : Error<"rvalue reference cannot bind to lvalue">;
+def err_lvalue_to_rvalue_ref : Error<"rvalue reference to type %0 cannot bind "
+ "to lvalue of type %1">;
def err_invalid_initialization : Error<
"invalid initialization of reference of type %0 from expression of type %1">;
def err_lvalue_to_rvalue_ambig_ref : Error<"rvalue reference cannot bind to lvalue "
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=123953&r1=123952&r2=123953&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Jan 20 19:04:33 2011
@@ -4140,6 +4140,7 @@
case FK_RValueReferenceBindingToLValue:
S.Diag(Kind.getLocation(), diag::err_lvalue_to_rvalue_ref)
+ << DestType.getNonReferenceType() << Args[0]->getType()
<< Args[0]->getSourceRange();
break;
Modified: cfe/trunk/test/SemaCXX/rval-references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/rval-references.cpp?rev=123953&r1=123952&r2=123953&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/rval-references.cpp (original)
+++ cfe/trunk/test/SemaCXX/rval-references.cpp Thu Jan 20 19:04:33 2011
@@ -28,9 +28,9 @@
void f() {
int &&virr1; // expected-error {{declaration of reference variable 'virr1' requires an initializer}}
int &&virr2 = 0;
- int &&virr3 = virr2; // expected-error {{rvalue reference cannot bind to lvalue}}
+ int &&virr3 = virr2; // expected-error {{rvalue reference to type 'int' cannot bind to lvalue of type 'int'}}
int i1 = 0;
- int &&virr4 = i1; // expected-error {{rvalue reference cannot bind to lvalue}}
+ int &&virr4 = i1; // expected-error {{rvalue reference to type 'int' cannot bind to lvalue of type 'int'}}
int &&virr5 = ret_irr();
int &&virr6 = static_cast<int&&>(i1);
(void)static_cast<not_int&&>(i1); // expected-error {{types are not compatible}}
More information about the cfe-commits
mailing list