Skip to content

Commit 6acbe85

Browse files
committed
[clang][bytecode] Reject dependent RequiresExprs
Fixes #152899
1 parent 1c1ec48 commit 6acbe85

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3879,6 +3879,8 @@ bool Compiler<Emitter>::VisitCXXUuidofExpr(const CXXUuidofExpr *E) {
38793879
template <class Emitter>
38803880
bool Compiler<Emitter>::VisitRequiresExpr(const RequiresExpr *E) {
38813881
assert(classifyPrim(E->getType()) == PT_Bool);
3882+
if (E->isValueDependent())
3883+
return false;
38823884
if (DiscardResult)
38833885
return true;
38843886
return this->emitConstBool(E->isSatisfied(), E);

clang/test/AST/ByteCode/cxx2a.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,17 @@ namespace GH150705 {
239239
constexpr const A& a = b;
240240
constexpr auto x = (a.*q)(); // both-error {{constant expression}}
241241
}
242+
243+
namespace DependentRequiresExpr {
244+
template <class T,
245+
bool = []() -> bool { // both-error {{not a constant expression}}
246+
if (requires { T::type; })
247+
return true;
248+
return false;
249+
}()>
250+
struct p {
251+
using type = void;
252+
};
253+
254+
template <class T> using P = p<T>::type; // both-note {{while checking a default template argument}}
255+
}

0 commit comments

Comments
 (0)