[clang] [clang][bytecode] Fix diagnostics for int128 enums (PR #151340)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 30 07:02:47 PDT 2025
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/151340
CheckEnumValue was not handling PT_IntAP/PT_IntAPS.
>From a12ca2ddd3a366afc90dc6798024b3671de3303f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Wed, 30 Jul 2025 15:59:10 +0200
Subject: [PATCH] [clang][bytecode] Fix diagnostics for int128 enums
CheckEnumValue was not handling PT_IntAP/PT_IntAPS.
---
clang/lib/AST/ByteCode/Opcodes.td | 2 +-
clang/test/AST/ByteCode/intap.cpp | 14 +++++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Opcodes.td b/clang/lib/AST/ByteCode/Opcodes.td
index abfed77750f87..5f2395efa9428 100644
--- a/clang/lib/AST/ByteCode/Opcodes.td
+++ b/clang/lib/AST/ByteCode/Opcodes.td
@@ -412,7 +412,7 @@ def CheckDecl : Opcode {
def CheckEnumValue : Opcode {
let Args = [ArgEnumDecl];
- let Types = [FixedSizeIntegralTypeClass];
+ let Types = [IntegralTypeClass];
let HasGroup = 1;
}
diff --git a/clang/test/AST/ByteCode/intap.cpp b/clang/test/AST/ByteCode/intap.cpp
index 68883871ffd26..05ab319bf16df 100644
--- a/clang/test/AST/ByteCode/intap.cpp
+++ b/clang/test/AST/ByteCode/intap.cpp
@@ -292,7 +292,19 @@ constexpr int shifts() { // both-error {{never produces a constant expression}}
(void)(2 << b); // ref-warning {{shift count is negative}}
return 1;
}
-#endif
+namespace UnderlyingInt128 {
+ enum F {
+ a = (__int128)-1
+ };
+
+ constexpr int foo() { // both-error {{never produces a constant expression}}
+ F f = (F)(__int128)10; // both-note 2{{integer value 10 is outside the valid range of values [-1, 0] for the enumeration type 'F'}}
+ return (int)f;
+ }
+ static_assert(foo() == 0, ""); // both-error {{not an integral constant expression}} \
+ // both-note {{in call to}}
+}
+#endif
#endif
More information about the cfe-commits
mailing list