https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/87144
>From 8a0d7c30b2e0efae395143bcd599f3de8d018394 Mon Sep 17 00:00:00 2001 From: huqizhi <huqi...@feysh.com> Date: Sat, 30 Mar 2024 14:47:00 +0800 Subject: [PATCH] [Clang][Sema] Skip checking anonymous enum in using enum declaration --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/Sema/SemaDecl.cpp | 4 ++++ clang/test/SemaCXX/PR86790.cpp | 9 +++++++++ 3 files changed, 14 insertions(+) create mode 100644 clang/test/SemaCXX/PR86790.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 232de0d7d8bb73..39f896652d03d5 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -459,6 +459,7 @@ Bug Fixes to C++ Support following the first `::` were ignored). - Fix an out-of-bounds crash when checking the validity of template partial specializations. (part of #GH86757). - Fix an issue caused by not handling invalid cases when substituting into the parameter mapping of a constraint. Fixes (#GH86757). +- 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 0bd88ece2aa544..594ebe56f4f4a8 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 00000000000000..1e9f3e1f467e5f --- /dev/null +++ b/clang/test/SemaCXX/PR86790.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s +// expected-no-diagnostics + +enum {A, S, D, F}; +int main() { + using asdf = decltype(A); + using enum asdf; // this line causes the crash + return 0; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits