https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/155230
Fixes #152899 >From 6acbe858dba0195b8b0ecbe3b4a69c6fc07f5f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com> Date: Mon, 25 Aug 2025 12:22:20 +0200 Subject: [PATCH] [clang][bytecode] Reject dependent RequiresExprs Fixes #152899 --- clang/lib/AST/ByteCode/Compiler.cpp | 2 ++ clang/test/AST/ByteCode/cxx2a.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index e3235d34e230e..a98c0acb4f660 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -3879,6 +3879,8 @@ bool Compiler<Emitter>::VisitCXXUuidofExpr(const CXXUuidofExpr *E) { template <class Emitter> bool Compiler<Emitter>::VisitRequiresExpr(const RequiresExpr *E) { assert(classifyPrim(E->getType()) == PT_Bool); + if (E->isValueDependent()) + return false; if (DiscardResult) return true; return this->emitConstBool(E->isSatisfied(), E); diff --git a/clang/test/AST/ByteCode/cxx2a.cpp b/clang/test/AST/ByteCode/cxx2a.cpp index 744c99eaa1e68..533173d84792f 100644 --- a/clang/test/AST/ByteCode/cxx2a.cpp +++ b/clang/test/AST/ByteCode/cxx2a.cpp @@ -239,3 +239,17 @@ namespace GH150705 { constexpr const A& a = b; constexpr auto x = (a.*q)(); // both-error {{constant expression}} } + +namespace DependentRequiresExpr { + template <class T, + bool = []() -> bool { // both-error {{not a constant expression}} + if (requires { T::type; }) + return true; + return false; + }()> + struct p { + using type = void; + }; + + template <class T> using P = p<T>::type; // both-note {{while checking a default template argument}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits