diff options
author | Timm Bäder <tbaeder@redhat.com> | 2024-01-31 15:51:48 +0100 |
---|---|---|
committer | Timm Bäder <tbaeder@redhat.com> | 2024-02-01 08:15:11 +0100 |
commit | 48f8b74c35991fd3842e135481960449b1e25363 (patch) | |
tree | b43f0f56fc46a22168cba7b4b029ad8d3c3f35a5 | |
parent | fa98e2861dadaf436b0eb4b38e96a2ccf7c41072 (diff) |
[clang][Interp] Support GenericSelectionExprs
Just delegate to the resulting expression.
-rw-r--r-- | clang/lib/AST/Interp/ByteCodeExprGen.cpp | 6 | ||||
-rw-r--r-- | clang/lib/AST/Interp/ByteCodeExprGen.h | 1 | ||||
-rw-r--r-- | clang/test/Sema/c2x-auto.c | 1 | ||||
-rw-r--r-- | clang/test/Sema/c2x-bool.c | 1 |
4 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index c0721b0daf9a..a93635a9f688 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -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; diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h index ec88f31ae516..1710b4446432 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.h +++ b/clang/lib/AST/Interp/ByteCodeExprGen.h @@ -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; diff --git a/clang/test/Sema/c2x-auto.c b/clang/test/Sema/c2x-auto.c index 7cbd1db31315..97754b2fb836 100644 --- a/clang/test/Sema/c2x-auto.c +++ b/clang/test/Sema/c2x-auto.c @@ -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}} diff --git a/clang/test/Sema/c2x-bool.c b/clang/test/Sema/c2x-bool.c index 0bc147228fda..98cb8507359d 100644 --- a/clang/test/Sema/c2x-bool.c +++ b/clang/test/Sema/c2x-bool.c @@ -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)); |