Author: Timm Baeder
Date: 2025-07-31T05:59:17+02:00
New Revision: 1b9ee0bb74f23e48076d97267171cb92c3f63658

URL: 
https://github.com/llvm/llvm-project/commit/1b9ee0bb74f23e48076d97267171cb92c3f63658
DIFF: 
https://github.com/llvm/llvm-project/commit/1b9ee0bb74f23e48076d97267171cb92c3f63658.diff

LOG: [clang][bytecode] Fix diagnostics for int128 enums (#151340)

CheckEnumValue was not handling PT_IntAP/PT_IntAPS.

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Opcodes.td
    clang/test/AST/ByteCode/intap.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/Opcodes.td 
b/clang/lib/AST/ByteCode/Opcodes.td
index 54abf22e59393..95a44333e8e04 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


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to