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::VisitCXXUuidofExpr(const CXXUuidofExpr *E) { template bool Compiler::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 bool { // both-error {{not a constant expression}} + if (requires { T::type; }) + return true; + return false; + }()> + struct p { + using type = void; + }; + + template using P = p::type; // both-note {{while checking a default template argument}} +}