https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/67147
None >From 80013d2e1b70aed0f7e225fab72136b6b4599cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com> Date: Fri, 22 Sep 2023 16:27:11 +0200 Subject: [PATCH] [clang][Interp] Handle CXXScalarValueInitExprs --- clang/lib/AST/Interp/ByteCodeExprGen.cpp | 6 ++++++ clang/lib/AST/Interp/ByteCodeExprGen.h | 1 + clang/test/AST/Interp/literals.cpp | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index e813d4fa651ceaf..c804bab7ce567d0 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1488,6 +1488,12 @@ bool ByteCodeExprGen<Emitter>::VisitOffsetOfExpr(const OffsetOfExpr *E) { return this->emitOffsetOf(T, E, E); } +template <class Emitter> +bool ByteCodeExprGen<Emitter>::VisitCXXScalarValueInitExpr( + const CXXScalarValueInitExpr *E) { + return this->visitZeroInitializer(E->getType(), E); +} + 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 47a3f75f13459d0..7cfe4d9251c5f05 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.h +++ b/clang/lib/AST/Interp/ByteCodeExprGen.h @@ -106,6 +106,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>, bool VisitCXXConstructExpr(const CXXConstructExpr *E); bool VisitSourceLocExpr(const SourceLocExpr *E); bool VisitOffsetOfExpr(const OffsetOfExpr *E); + bool VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *E); protected: bool visitExpr(const Expr *E) override; diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp index ceda59405ea9105..6ae8df79f52accb 100644 --- a/clang/test/AST/Interp/literals.cpp +++ b/clang/test/AST/Interp/literals.cpp @@ -31,6 +31,13 @@ static_assert(b, ""); constexpr int one = true; static_assert(one == 1, ""); +constexpr bool b2 = bool(); +static_assert(!b2, ""); +constexpr int ScalarInitInt = int(); +static_assert(ScalarInitInt == 0, ""); +constexpr float ScalarInitFloat = float(); +static_assert(ScalarInitInt == 0.0f, ""); + namespace IntegralCasts { constexpr int i = 12; constexpr unsigned int ui = i; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits