Skip to content

Commit 58ceefe

Browse files
committed
[clang][Interp] Support ChooseExprs
1 parent 2147a2a commit 58ceefe

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,11 @@ bool ByteCodeExprGen<Emitter>::VisitGenericSelectionExpr(
19481948
return this->delegate(E->getResultExpr());
19491949
}
19501950

1951+
template <class Emitter>
1952+
bool ByteCodeExprGen<Emitter>::VisitChooseExpr(const ChooseExpr *E) {
1953+
return this->delegate(E->getChosenSubExpr());
1954+
}
1955+
19511956
template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
19521957
if (E->containsErrors())
19531958
return false;

clang/lib/AST/Interp/ByteCodeExprGen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
109109
bool VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *E);
110110
bool VisitSizeOfPackExpr(const SizeOfPackExpr *E);
111111
bool VisitGenericSelectionExpr(const GenericSelectionExpr *E);
112+
bool VisitChooseExpr(const ChooseExpr *E);
112113

113114
protected:
114115
bool visitExpr(const Expr *E) override;

clang/test/AST/Interp/c.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,6 @@ void f (int z) {
9595
// pedantic-ref-error {{'default' statement not in switch}}
9696
}
9797
}
98+
99+
int expr;
100+
int chooseexpr[__builtin_choose_expr(1, 1, expr)];

0 commit comments

Comments
 (0)