Skip to content

Commit 7dfb6f5

Browse files
committed
[clang][Interp] Fix ignored RequiresExprs
Also ConceptSpecializationExpr, although I don't have a test case at hand for those.
1 parent cd683bd commit 7dfb6f5

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,13 +2440,17 @@ bool ByteCodeExprGen<Emitter>::VisitCXXUuidofExpr(const CXXUuidofExpr *E) {
24402440
template <class Emitter>
24412441
bool ByteCodeExprGen<Emitter>::VisitRequiresExpr(const RequiresExpr *E) {
24422442
assert(classifyPrim(E->getType()) == PT_Bool);
2443+
if (DiscardResult)
2444+
return true;
24432445
return this->emitConstBool(E->isSatisfied(), E);
24442446
}
24452447

24462448
template <class Emitter>
24472449
bool ByteCodeExprGen<Emitter>::VisitConceptSpecializationExpr(
24482450
const ConceptSpecializationExpr *E) {
24492451
assert(classifyPrim(E->getType()) == PT_Bool);
2452+
if (DiscardResult)
2453+
return true;
24502454
return this->emitConstBool(E->isSatisfied(), E);
24512455
}
24522456

clang/test/AST/Interp/literals.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,8 @@ namespace DiscardExprs {
985985
__uuidof(GuidType);
986986
__uuidof(number); // both-error {{cannot call operator __uuidof on a type with no GUID}}
987987

988+
requires{false;};
989+
988990
return 0;
989991
}
990992
static_assert(ignoredExprs() == 0, "");

0 commit comments

Comments
 (0)