"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;
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());
}
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;
}
}
// 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}}
}
}
// 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}}
}
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 {