Skip to content

Commit 1b9ee0b

Browse files
authored
[clang][bytecode] Fix diagnostics for int128 enums (#151340)
CheckEnumValue was not handling PT_IntAP/PT_IntAPS.
1 parent ebf96f9 commit 1b9ee0b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

clang/lib/AST/ByteCode/Opcodes.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def CheckDecl : Opcode {
412412

413413
def CheckEnumValue : Opcode {
414414
let Args = [ArgEnumDecl];
415-
let Types = [FixedSizeIntegralTypeClass];
415+
let Types = [IntegralTypeClass];
416416
let HasGroup = 1;
417417
}
418418

clang/test/AST/ByteCode/intap.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,19 @@ constexpr int shifts() { // both-error {{never produces a constant expression}}
292292
(void)(2 << b); // ref-warning {{shift count is negative}}
293293
return 1;
294294
}
295-
#endif
296295

296+
namespace UnderlyingInt128 {
297+
enum F {
298+
a = (__int128)-1
299+
};
300+
301+
constexpr int foo() { // both-error {{never produces a constant expression}}
302+
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'}}
303+
return (int)f;
304+
}
305+
static_assert(foo() == 0, ""); // both-error {{not an integral constant expression}} \
306+
// both-note {{in call to}}
307+
}
308+
#endif
297309

298310
#endif

0 commit comments

Comments
 (0)