https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/155230

>From fa6fbec9dbe7d09ca3f9256f8c72e3223f4e4249 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 c36cb644282d8..e369f2eb182d2 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

Reply via email to