[clang][Interp] Handle ObjCBoolLiteralExprs
Emit them just like the others, but these are integer typed.
This commit is contained in:
parent
c5f68a711c
commit
5e8626c920
@ -1985,6 +1985,15 @@ bool ByteCodeExprGen<Emitter>::VisitChooseExpr(const ChooseExpr *E) {
|
||||
return this->delegate(E->getChosenSubExpr());
|
||||
}
|
||||
|
||||
template <class Emitter>
|
||||
bool ByteCodeExprGen<Emitter>::VisitObjCBoolLiteralExpr(
|
||||
const ObjCBoolLiteralExpr *E) {
|
||||
if (DiscardResult)
|
||||
return true;
|
||||
|
||||
return this->emitConst(E->getValue(), E);
|
||||
}
|
||||
|
||||
template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
|
||||
if (E->containsErrors())
|
||||
return false;
|
||||
|
||||
@ -110,6 +110,7 @@ public:
|
||||
bool VisitSizeOfPackExpr(const SizeOfPackExpr *E);
|
||||
bool VisitGenericSelectionExpr(const GenericSelectionExpr *E);
|
||||
bool VisitChooseExpr(const ChooseExpr *E);
|
||||
bool VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *E);
|
||||
|
||||
protected:
|
||||
bool visitExpr(const Expr *E) override;
|
||||
|
||||
@ -7,6 +7,10 @@ typedef __INTPTR_TYPE__ intptr_t;
|
||||
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
||||
|
||||
_Static_assert(1, "");
|
||||
|
||||
_Static_assert(__objc_yes, "");
|
||||
_Static_assert(!__objc_no, "");
|
||||
|
||||
_Static_assert(0 != 1, "");
|
||||
_Static_assert(1.0 == 1.0, ""); // pedantic-ref-warning {{not an integer constant expression}} \
|
||||
// pedantic-expected-warning {{not an integer constant expression}}
|
||||
|
||||
@ -27,6 +27,9 @@ static_assert(number != 10, ""); // expected-error{{failed}} \
|
||||
// expected-note{{evaluates to}} \
|
||||
// ref-note{{evaluates to}}
|
||||
|
||||
static_assert(__objc_yes, "");
|
||||
static_assert(!__objc_no, "");
|
||||
|
||||
constexpr bool b = number;
|
||||
static_assert(b, "");
|
||||
constexpr int one = true;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
// RUN: %clang_cc1 %s -verify -fsyntax-only
|
||||
// RUN: %clang_cc1 %s -verify -fsyntax-only -fexperimental-new-constant-interpreter
|
||||
|
||||
typedef signed char BOOL;
|
||||
#define YES __objc_yes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user