Skip to content

Commit 2147a2a

Browse files
committed
[clang][Interp] Not all TypeTraitExprs are of bool type
In C, they return an integer, so emit their value as such.
1 parent 374a600 commit 2147a2a

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,9 @@ template <class Emitter>
16681668
bool ByteCodeExprGen<Emitter>::VisitTypeTraitExpr(const TypeTraitExpr *E) {
16691669
if (DiscardResult)
16701670
return true;
1671-
return this->emitConstBool(E->getValue(), E);
1671+
if (E->getType()->isBooleanType())
1672+
return this->emitConstBool(E->getValue(), E);
1673+
return this->emitConst(E->getValue(), E);
16721674
}
16731675

16741676
template <class Emitter>

clang/test/Sema/PR2919-builtin-types-compat-strips-crv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -fsyntax-only %s
2+
// RUN: %clang_cc1 -fsyntax-only %s -fexperimental-new-constant-interpreter
23

34
typedef struct foo T0;
45
typedef const struct foo T1;

clang/test/Sema/auto-type.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 %s -fsyntax-only -Wno-strict-prototypes -verify -pedantic -std=c11
2+
// RUN: %clang_cc1 %s -fsyntax-only -Wno-strict-prototypes -verify -pedantic -std=c11 -fexperimental-new-constant-interpreter
23

34
__auto_type a = 5; // expected-warning {{'__auto_type' is a GNU extension}}
45
__extension__ __auto_type a1 = 5;

0 commit comments

Comments
 (0)