Skip to content

Commit e64fe2a

Browse files
committed
We're in a constant context in the ConstantEmitter.
llvm-svn: 348029
1 parent 601d311 commit e64fe2a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

clang/lib/CodeGen/CGExprConstant.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,8 @@ llvm::Constant *ConstantEmitter::tryEmitPrivate(const Expr *E,
15521552
if (destType->isReferenceType())
15531553
Success = E->EvaluateAsLValue(Result, CGM.getContext());
15541554
else
1555-
Success = E->EvaluateAsRValue(Result, CGM.getContext());
1555+
Success = E->EvaluateAsRValue(Result, CGM.getContext(),
1556+
/* InConstantContext */ true);
15561557

15571558
llvm::Constant *C;
15581559
if (Success && !Result.HasSideEffects)

clang/test/CodeGen/builtin-constant-p.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,14 @@ static void src_fn(void) {
157157
void test14() {
158158
assign(dest_p, src_fn);
159159
}
160+
161+
struct test15_s {
162+
const char *name;
163+
int num_args;
164+
};
165+
166+
extern int test15_v;
167+
168+
struct test15_s tcg_op_defs_org_x86_64[] = {
169+
{"tag", __builtin_constant_p(test15_v) && !test15_v ? 0x10 : 0 },
170+
};

0 commit comments

Comments
 (0)