forked from OSchip/llvm-project
Improve the diagnostic that complains about binding an rvalue
reference to an lvalue. llvm-svn: 123953
This commit is contained in:
parent
24f2e8ec00
commit
bed28f7629
|
@ -767,7 +767,8 @@ def err_init_conversion_failed : Error<
|
|||
"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 "
|
||||
|
|
|
@ -4140,6 +4140,7 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
|
||||
case FK_RValueReferenceBindingToLValue:
|
||||
S.Diag(Kind.getLocation(), diag::err_lvalue_to_rvalue_ref)
|
||||
<< DestType.getNonReferenceType() << Args[0]->getType()
|
||||
<< Args[0]->getSourceRange();
|
||||
break;
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@ fun_type &&make_fun();
|
|||
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}}
|
||||
|
|
Loading…
Reference in New Issue