Don't warn that variables in C++ static member functions shadow fields. Fixes rdar://8900456.

llvm-svn: 124581
This commit is contained in:
Argyrios Kyrtzidis
2011-01-31 07:04:54 +00:00
parent 857dd06605
commit f46cc65f44
2 changed files with 19 additions and 0 deletions

View File

@@ -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:

View File

@@ -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.
}
}