[cfe-commits] r124581 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/warn-shadow.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Sun Jan 30 23:04:54 PST 2011
Author: akirtzidis
Date: Mon Jan 31 01:04:54 2011
New Revision: 124581
URL: http://llvm.org/viewvc/llvm-project?rev=124581&view=rev
Log:
Don't warn that variables in C++ static member functions shadow fields. Fixes rdar://8900456.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-shadow.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=124581&r1=124580&r2=124581&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jan 31 01:04:54 2011
@@ -3129,6 +3129,12 @@
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:
Modified: cfe/trunk/test/SemaCXX/warn-shadow.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-shadow.cpp?rev=124581&r1=124580&r2=124581&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-shadow.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-shadow.cpp Mon Jan 31 01:04:54 2011
@@ -42,3 +42,16 @@
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.
+}
+}
More information about the cfe-commits
mailing list