mirror of
https://github.com/intel/llvm.git
synced 2026-02-03 02:26:27 +08:00
Don't warn that variables in C++ static member functions shadow fields. Fixes rdar://8900456.
llvm-svn: 124581
This commit is contained in:
@@ -3129,6 +3129,12 @@ void Sema::CheckShadow(Scope *S, VarDecl *D, const LookupResult& R) {
|
||||
if (!isa<VarDecl>(ShadowedDecl) && !isa<FieldDecl>(ShadowedDecl))
|
||||
return;
|
||||
|
||||
// Fields are not shadowed by variables in C++ static methods.
|
||||
if (isa<FieldDecl>(ShadowedDecl))
|
||||
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDC))
|
||||
if (MD->isStatic())
|
||||
return;
|
||||
|
||||
if (VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
|
||||
if (shadowedVar->isExternC()) {
|
||||
// Don't warn for this case:
|
||||
|
||||
@@ -42,3 +42,16 @@ class B : A {
|
||||
int data;
|
||||
static int field;
|
||||
};
|
||||
|
||||
// rdar://8900456
|
||||
namespace rdar8900456 {
|
||||
struct Foo {
|
||||
static void Baz();
|
||||
private:
|
||||
int Bar;
|
||||
};
|
||||
|
||||
void Foo::Baz() {
|
||||
double Bar = 12; // Don't warn.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user