[clang] [clang][Interp] Implement IntegralAP::comp (PR #67954)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 1 23:17:10 PDT 2023
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/67954
None
>From fe7f8cddb7f4590f481fce3b99c7b56f8163d889 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sun, 1 Oct 2023 19:57:03 +0200
Subject: [PATCH] [clang][Interp] Implement IntegralAP::comp
---
clang/lib/AST/Interp/IntegralAP.h | 1 -
clang/test/AST/Interp/literals.cpp | 3 +++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/clang/lib/AST/Interp/IntegralAP.h b/clang/lib/AST/Interp/IntegralAP.h
index b2b367f30c238fe..b29aac2a73e3243 100644
--- a/clang/lib/AST/Interp/IntegralAP.h
+++ b/clang/lib/AST/Interp/IntegralAP.h
@@ -210,7 +210,6 @@ template <bool Signed> class IntegralAP final {
}
static bool comp(IntegralAP A, IntegralAP *R) {
- assert(false);
*R = IntegralAP(~A.V);
return false;
}
diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp
index b57a0e64c5fac32..864c91dd0003b9e 100644
--- a/clang/test/AST/Interp/literals.cpp
+++ b/clang/test/AST/Interp/literals.cpp
@@ -87,6 +87,9 @@ constexpr int128_t Error = __LDBL_MAX__; // ref-warning {{implicit conversion of
// expected-warning {{implicit conversion of out of range value}} \
// expected-error {{must be initialized by a constant expression}} \
// expected-note {{is outside the range of representable values of type}}
+
+ constexpr uint128_t UINT128_MAX = ~static_cast<uint128_t>(0);
+ static_assert(UINT128_MAX == static_cast<uint128_t>(-1), "");
}
#endif
More information about the cfe-commits
mailing list