Skip to content

Commit f620c5b

Browse files
authored
[clang][bytecode] Classify 1-bit unsigned integers as bool (#104662)
This happens for enum types with bool parent types. isBooleanType() returns false for them however. The previous version did the same thing by re-classifying the enum integer type, but that breaks with forward-declared enums.
1 parent 107f3ef commit f620c5b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

clang/lib/AST/ByteCode/Context.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,6 @@ std::optional<PrimType> Context::classify(QualType T) const {
135135
if (T->isAnyComplexType() || T->isVectorType())
136136
return std::nullopt;
137137

138-
if (const auto *ET = T->getAs<EnumType>())
139-
return classify(ET->getDecl()->getIntegerType());
140-
141138
if (T->isSignedIntegerOrEnumerationType()) {
142139
switch (Ctx.getIntWidth(T)) {
143140
case 64:
@@ -163,6 +160,9 @@ std::optional<PrimType> Context::classify(QualType T) const {
163160
return PT_Uint16;
164161
case 8:
165162
return PT_Uint8;
163+
case 1:
164+
// Might happen for enum types.
165+
return PT_Bool;
166166
default:
167167
return PT_IntAP;
168168
}

clang/test/AST/ByteCode/c.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,5 @@ void T1(void) {
295295
// pedantic-warning {{use of GNU statement expression extension}}
296296
}
297297

298-
298+
enum teste1 test1f(void), (*test1)(void) = test1f; // pedantic-warning {{ISO C forbids forward references to 'enum' types}}
299+
enum teste1 { TEST1 };

0 commit comments

Comments
 (0)