https://github.com/Serosh-commits updated https://github.com/llvm/llvm-project/pull/184210
>From d6eeca0f7e30ff37d051004b598e31c01f435125 Mon Sep 17 00:00:00 2001 From: Serosh-commits <[email protected]> Date: Thu, 5 Mar 2026 02:24:01 +0530 Subject: [PATCH] fix explicit incomplete enum --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/Sema/SemaOverload.cpp | 3 +++ clang/test/SemaCXX/gh183887.cpp | 8 ++++++++ 3 files changed, 12 insertions(+) create mode 100644 clang/test/SemaCXX/gh183887.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 18ce0f919daa9..82b80e2b287c5 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -334,6 +334,7 @@ Bug Fixes to C++ Support - Fixed a bug where captured variables in non-mutable lambdas were incorrectly treated as mutable when used inside decltype in the return type. (#GH180460) - Fixed a crash when evaluating uninitialized GCC vector/ext_vector_type vectors in ``constexpr``. (#GH180044) +- Fixed a crash when `explicit(bool)` is used with an incomplete enumeration. (#GH183887) - Fixed a crash on ``typeid`` of incomplete local types during template instantiation. (#GH63242), (#GH176397) - Fix initialization of GRO when GRO-return type mismatches, as part of CWG2563. (#GH98744) diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index e5c4c59e9ffbb..432f85a554d1c 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -6464,6 +6464,9 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, if (checkPlaceholderForOverload(S, From)) return ExprError(); + if (From->containsErrors()) + return S.ImpCastExprToType(From, T, CK_NoOp); + // C++1z [expr.const]p3: // A converted constant expression of type T is an expression, // implicitly converted to type T, where the converted diff --git a/clang/test/SemaCXX/gh183887.cpp b/clang/test/SemaCXX/gh183887.cpp new file mode 100644 index 0000000000000..d89b2d5068ea0 --- /dev/null +++ b/clang/test/SemaCXX/gh183887.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s + +namespace GH183887 { +enum E1 explicit(E1()); // expected-error {{ISO C++ forbids forward references to 'enum' types}} \ + // expected-error {{invalid use of incomplete type 'E1'}} \ + // expected-error {{'explicit' can only appear on non-static member functions}} \ + // expected-note {{forward declaration of 'GH183887::E1'}} +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
