Author: Timm Baeder Date: 2025-08-27T12:04:44+02:00 New Revision: 16494be2e8861ae988cb5decbede1f9242286b92
URL: https://github.com/llvm/llvm-project/commit/16494be2e8861ae988cb5decbede1f9242286b92 DIFF: https://github.com/llvm/llvm-project/commit/16494be2e8861ae988cb5decbede1f9242286b92.diff LOG: [clang][bytecode] Reject dependent RequiresExprs (#155230) Fixes #152899 Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp clang/test/AST/ByteCode/cxx2a.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index ea6195cc11ef9..8ed9e64f5f8ff 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -3895,6 +3895,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