Better wording for reference self-initialization warning.
llvm-svn: 162198
This commit is contained in:
parent
4a156c1b80
commit
d799a2b3b9
|
@ -1216,9 +1216,16 @@ def note_uninit_reference_member : Note<
|
|||
"uninitialized reference member is here">;
|
||||
def warn_field_is_uninit : Warning<"field is uninitialized when used here">,
|
||||
InGroup<Uninitialized>;
|
||||
def warn_reference_field_is_uninit : Warning<
|
||||
"reference is not yet bound to a value when used here">,
|
||||
InGroup<Uninitialized>;
|
||||
def warn_uninit_self_reference_in_init : Warning<
|
||||
"variable %0 is uninitialized when used within its own initialization">,
|
||||
InGroup<Uninitialized>;
|
||||
def warn_uninit_self_reference_in_reference_init : Warning<
|
||||
"reference %0 is not yet bound to a value when used within its own"
|
||||
" initialization">,
|
||||
InGroup<Uninitialized>;
|
||||
def warn_uninit_var : Warning<
|
||||
"variable %0 is uninitialized when %select{used here|captured by block}1">,
|
||||
InGroup<Uninitialized>, DefaultIgnore;
|
||||
|
|
|
@ -6275,8 +6275,11 @@ namespace {
|
|||
if (OrigDecl != ReferenceDecl) return;
|
||||
LookupResult Result(S, DRE->getNameInfo(), Sema::LookupOrdinaryName,
|
||||
Sema::NotForRedeclaration);
|
||||
unsigned diag = isReferenceType
|
||||
? diag::warn_uninit_self_reference_in_reference_init
|
||||
: diag::warn_uninit_self_reference_in_init;
|
||||
S.DiagRuntimeBehavior(DRE->getLocStart(), DRE,
|
||||
S.PDiag(diag::warn_uninit_self_reference_in_init)
|
||||
S.PDiag(diag)
|
||||
<< Result.getLookupName()
|
||||
<< OrigDecl->getLocation()
|
||||
<< DRE->getSourceRange());
|
||||
|
|
|
@ -2080,7 +2080,10 @@ namespace {
|
|||
}
|
||||
|
||||
if (VD == ME->getMemberDecl() && isa<CXXThisExpr>(Base)) {
|
||||
S.Diag(ME->getExprLoc(), diag::warn_field_is_uninit);
|
||||
unsigned diag = VD->getType()->isReferenceType()
|
||||
? diag::warn_reference_field_is_uninit
|
||||
: diag::warn_field_is_uninit;
|
||||
S.Diag(ME->getExprLoc(), diag);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,6 @@ struct TS {
|
|||
|
||||
// rdar://11345441
|
||||
int* f5() {
|
||||
int& i = i; // expected-warning {{Assigned value is garbage or undefined}} expected-note {{binding reference variable 'i' here}} expected-warning{{variable 'i' is uninitialized when used within its own initialization}}
|
||||
int& i = i; // expected-warning {{Assigned value is garbage or undefined}} expected-note {{binding reference variable 'i' here}} expected-warning{{reference 'i' is not yet bound to a value when used within its own initialization}}
|
||||
return &i; // expected-warning {{address of stack memory associated with local variable 'i' returned}}
|
||||
}
|
||||
|
|
|
@ -136,4 +136,4 @@ namespace PR8608 {
|
|||
}
|
||||
|
||||
// The following crashed trying to recursively evaluate the LValue.
|
||||
const int &do_not_crash = do_not_crash; // expected-warning{{variable 'do_not_crash' is uninitialized when used within its own initialization}}
|
||||
const int &do_not_crash = do_not_crash; // expected-warning{{reference 'do_not_crash' is not yet bound to a value when used within its own initialization}}
|
||||
|
|
|
@ -380,15 +380,15 @@ namespace statics {
|
|||
}
|
||||
|
||||
namespace references {
|
||||
int &a = a; // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
|
||||
int &a = a; // expected-warning{{reference 'a' is not yet bound to a value when used within its own initialization}}
|
||||
|
||||
struct S {
|
||||
S() : a(a) {} // expected-warning{{field is uninitialized when used here}}
|
||||
S() : a(a) {} // expected-warning{{reference is not yet bound to a value when used here}}
|
||||
int &a;
|
||||
};
|
||||
|
||||
void f() {
|
||||
int &a = a; // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
|
||||
int &a = a; // expected-warning{{reference 'a' is not yet bound to a value when used within its own initialization}}
|
||||
}
|
||||
|
||||
struct T {
|
||||
|
|
Loading…
Reference in New Issue