[clang] [Clang] skip shadow warnings for enum constants in distinct class scopes (PR #115656)

Oleksandr T. via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 12 05:18:48 PST 2024


================
@@ -8341,6 +8341,11 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
     // shadowing context, but that's just a false negative.
   }
 
+  // Skip shadowing check if we're in a class scope, dealing with an enum
+  // constant in a different context.
+  if (S->isClassScope() && isa<EnumConstantDecl>(D) &&
----------------
a-tarasyuk wrote:

I think in this case `NewDC` refers to `EnumDeclaration`, so maybe checking `RedeclContext` would work, though it needs verification. Is relying on `Scope` not permitted here?



https://github.com/llvm/llvm-project/pull/115656


More information about the cfe-commits mailing list