aboutsummaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/docs/ReleaseNotes.rst1
-rw-r--r--clang/lib/Sema/SemaDecl.cpp4
-rw-r--r--clang/test/SemaCXX/PR86790.cpp32
3 files changed, 37 insertions, 0 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b11a811..28e8ddb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -503,6 +503,7 @@ Bug Fixes to C++ Support
- Fix crash when inheriting from a cv-qualified type. Fixes:
(`#35603 <https://github.com/llvm/llvm-project/issues/35603>`_)
+- Fix a crash when the using enum declaration uses an anonymous enumeration. Fixes (#GH86790).
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index cbd84dd..c790dab 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1537,6 +1537,10 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
cast<FunctionDecl>(D)->isFunctionTemplateSpecialization())
return;
+ if (isa<UsingEnumDecl>(D) && D->getDeclName().isEmpty()) {
+ S->AddDecl(D);
+ return;
+ }
// If this replaces anything in the current scope,
IdentifierResolver::iterator I = IdResolver.begin(D->getDeclName()),
IEnd = IdResolver.end();
diff --git a/clang/test/SemaCXX/PR86790.cpp b/clang/test/SemaCXX/PR86790.cpp
new file mode 100644
index 0000000..09e9bb3
--- /dev/null
+++ b/clang/test/SemaCXX/PR86790.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s
+
+enum {A, S, D, F};
+int main() {
+ using asdf = decltype(A);
+ using enum asdf; // this line causes the crash
+ return 0;
+}
+
+namespace N1 {
+ enum {A, S, D, F};
+ constexpr struct T {
+ using asdf = decltype(A);
+ using enum asdf;
+ } t;
+
+ static_assert(t.D == D);
+ static_assert(T::S == S);
+}
+
+namespace N2 {
+ enum {A, S, D, F};
+ constexpr struct T {
+ struct {
+ using asdf = decltype(A);
+ using enum asdf;
+ } inner;
+ } t;
+
+ static_assert(t.inner.D == D);
+ static_assert(t.D == D); // expected-error {{no member named 'D' in 'N2::T'}}
+}