[clang][Interp] Support GenericSelectionExprs

Just delegate to the resulting expression.
This commit is contained in:
Timm Bäder 2024-01-31 15:51:48 +01:00
parent fa98e2861d
commit 48f8b74c35
4 changed files with 9 additions and 0 deletions

View File

@ -1940,6 +1940,12 @@ bool ByteCodeExprGen<Emitter>::VisitSizeOfPackExpr(const SizeOfPackExpr *E) {
return this->emitConst(E->getPackLength(), E);
}
template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitGenericSelectionExpr(
const GenericSelectionExpr *E) {
return this->delegate(E->getResultExpr());
}
template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
if (E->containsErrors())
return false;

View File

@ -108,6 +108,7 @@ public:
bool VisitOffsetOfExpr(const OffsetOfExpr *E);
bool VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *E);
bool VisitSizeOfPackExpr(const SizeOfPackExpr *E);
bool VisitGenericSelectionExpr(const GenericSelectionExpr *E);
protected:
bool visitExpr(const Expr *E) override;

View File

@ -1,4 +1,5 @@
// RUN: %clang_cc1 -std=c2x -verify -pedantic -Wno-comments %s
// RUN: %clang_cc1 -std=c2x -verify -pedantic -Wno-comments %s -fexperimental-new-constant-interpreter
void test_basic_types(void) {
auto undefined; // expected-error {{declaration of variable 'undefined' with deduced type 'auto' requires an initializer}}

View File

@ -1,4 +1,5 @@
// RUN: %clang_cc1 -std=c2x -fsyntax-only -verify %s
// RUN: %clang_cc1 -std=c2x -fsyntax-only -verify %s -fexperimental-new-constant-interpreter
_Static_assert(_Generic(true, _Bool : 1, default: 0));
_Static_assert(_Generic(false, _Bool : 1, default: 0));