Skip to content

Commit 20b9d9b

Browse files
committed
[Clang] fixed false positive redeclaration error for using enum in nested scopes
1 parent 962c421 commit 20b9d9b

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,10 @@ Bug Fixes in This Version
770770
- In C23, something like ``[[/*possible attributes*/]];`` is an attribute
771771
declaration, not a statement. So it is not allowed by the syntax in places
772772
where a statement is required, specifically as the secondary block of a
773-
selection or iteration statement. This differs from C++, since C++ allows
773+
selection or iteration statement. This differs from C++, since C++ allows
774774
declaration statements. Clang now emits a warning for these patterns. (#GH141659)
775+
- Fixed false positives for redeclaration errors of using enum in
776+
nested scopes. (#GH147495)
775777

776778
Bug Fixes to Compiler Builtins
777779
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13308,7 +13308,7 @@ NamedDecl *Sema::BuildUsingEnumDeclaration(Scope *S, AccessSpecifier AS,
1330813308
LookupResult Previous(*this, UsingEnumName, LookupUsingDeclName,
1330913309
RedeclarationKind::ForVisibleRedeclaration);
1331013310

13311-
LookupName(Previous, S);
13311+
LookupQualifiedName(Previous, CurContext);
1331213312

1331313313
for (NamedDecl *D : Previous)
1331413314
if (UsingEnumDecl *UED = dyn_cast<UsingEnumDecl>(D))

clang/test/SemaCXX/cxx20-using-enum.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,18 @@ void f(int a) {
274274
}
275275
}
276276

277+
namespace GH147495 {
278+
struct S {
279+
enum class E { A };
280+
using enum E;
281+
282+
struct S1 {
283+
using enum E;
284+
};
285+
286+
struct S2 {
287+
using E::A;
288+
};
289+
};
290+
}
277291
#endif

0 commit comments

Comments
 (0)