Skip to content

Conversation

@tbaederr
Copy link
Contributor

CheckEnumValue was not handling PT_IntAP/PT_IntAPS.

CheckEnumValue was not handling PT_IntAP/PT_IntAPS.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels Jul 30, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 30, 2025

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

CheckEnumValue was not handling PT_IntAP/PT_IntAPS.


Full diff: https://github.com/llvm/llvm-project/pull/151340.diff

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/Opcodes.td (+1-1)
  • (modified) clang/test/AST/ByteCode/intap.cpp (+13-1)
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

@tbaederr tbaederr merged commit 1b9ee0b into llvm:main Jul 31, 2025
13 checks passed
@smeenai
Copy link
Collaborator

smeenai commented Jul 31, 2025

I'm seeing some internal test failures after this change:

error: diagnostics with 'error' severity expected but not seen: 
  File clang/test/AST/ByteCode/intap.cpp Line 305 'both-error': not an integral constant expression
error: diagnostics with 'error' severity seen but not expected: 
  File clang/test/AST/ByteCode/intap.cpp Line 305: static assertion failed due to requirement 'foo() == 0': 
error: diagnostics with 'note' severity expected but not seen: 
  File clang/test/AST/ByteCode/intap.cpp Line 302 'both-note': integer value 10 is outside the valid range of values [-1, 0] for the enumeration type 'F'
  File clang/test/AST/ByteCode/intap.cpp Line 305 'both-note': in call to
error: diagnostics with 'note' severity seen but not expected: 
  File clang/test/AST/ByteCode/intap.cpp Line 305: expression evaluates to '10 == 0'
5 errors generated.

Any idea what might be happening?

@smeenai
Copy link
Collaborator

smeenai commented Jul 31, 2025

Apologies, this is a bad interaction with a local patch we had, not any issue with your change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants