diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index ca7e529041188..01555b0fc7dac 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1948,6 +1948,11 @@ bool ByteCodeExprGen::VisitGenericSelectionExpr( return this->delegate(E->getResultExpr()); } +template +bool ByteCodeExprGen::VisitChooseExpr(const ChooseExpr *E) { + return this->delegate(E->getChosenSubExpr()); +} + template bool ByteCodeExprGen::discard(const Expr *E) { if (E->containsErrors()) return false; diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h index 1710b4446432b..4ed5d31e343a6 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.h +++ b/clang/lib/AST/Interp/ByteCodeExprGen.h @@ -109,6 +109,7 @@ class ByteCodeExprGen : public ConstStmtVisitor, bool>, bool VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *E); bool VisitSizeOfPackExpr(const SizeOfPackExpr *E); bool VisitGenericSelectionExpr(const GenericSelectionExpr *E); + bool VisitChooseExpr(const ChooseExpr *E); protected: bool visitExpr(const Expr *E) override; diff --git a/clang/test/AST/Interp/c.c b/clang/test/AST/Interp/c.c index 385944d643a30..df3807b371dea 100644 --- a/clang/test/AST/Interp/c.c +++ b/clang/test/AST/Interp/c.c @@ -95,3 +95,6 @@ void f (int z) { // pedantic-ref-error {{'default' statement not in switch}} } } + +int expr; +int chooseexpr[__builtin_choose_expr(1, 1, expr)];