Author: sberg Date: Wed Apr 5 03:36:58 2017 New Revision: 299522 URL: http://llvm.org/viewvc/llvm-project?rev=299522&view=rev Log: Don't issue a warning if the shadowing declaration is in a class
Follow-up to r299363 "Enhance -Wshadow to warn when shadowing typedefs or type aliases". Patch by Ahmed Asadi. Differential Revision: https://reviews.llvm.org/D31235 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=299522&r1=299521&r2=299522&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Apr 5 03:36:58 2017 @@ -6744,6 +6744,10 @@ NamedDecl *Sema::getShadowedDeclaration( /// if it doesn't shadow any declaration or shadowing warnings are disabled. NamedDecl *Sema::getShadowedDeclaration(const TypedefNameDecl *D, const LookupResult &R) { + // Don't warn if typedef declaration is part of a class + if (D->getDeclContext()->isRecord()) + return nullptr; + if (!shouldWarnIfShadowedDecl(Diags, R)) return nullptr; Modified: cfe/trunk/test/SemaCXX/warn-shadow.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-shadow.cpp?rev=299522&r1=299521&r2=299522&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/warn-shadow.cpp (original) +++ cfe/trunk/test/SemaCXX/warn-shadow.cpp Wed Apr 5 03:36:58 2017 @@ -87,6 +87,16 @@ class A { } }; +struct path { + using value_type = char; + typedef char value_type2; + struct iterator { + using value_type = path; // no warning + typedef path value_type2; // no warning + }; +}; + + // TODO: this should warn, <rdar://problem/5018057> class B : A { int data; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits