We're in a constant context in the ConstantEmitter.
authorBill Wendling <isanbard@gmail.com>
Fri, 30 Nov 2018 20:40:06 +0000 (20:40 +0000)
committerBill Wendling <isanbard@gmail.com>
Fri, 30 Nov 2018 20:40:06 +0000 (20:40 +0000)
llvm-svn: 348029

clang/lib/CodeGen/CGExprConstant.cpp
clang/test/CodeGen/builtin-constant-p.c

index eb5e010..ca86e10 100644 (file)
@@ -1552,7 +1552,8 @@ llvm::Constant *ConstantEmitter::tryEmitPrivate(const Expr *E,
   if (destType->isReferenceType())
     Success = E->EvaluateAsLValue(Result, CGM.getContext());
   else
-    Success = E->EvaluateAsRValue(Result, CGM.getContext());
+    Success = E->EvaluateAsRValue(Result, CGM.getContext(),
+                                  /* InConstantContext */ true);
 
   llvm::Constant *C;
   if (Success && !Result.HasSideEffects)
index 5cdcc72..943d288 100644 (file)
@@ -157,3 +157,14 @@ static void src_fn(void) {
 void test14() {
   assign(dest_p, src_fn);
 }
+
+struct test15_s {
+  const char *name;
+  int num_args;
+};
+
+extern int test15_v;
+
+struct test15_s tcg_op_defs_org_x86_64[] = {
+    {"tag", __builtin_constant_p(test15_v) && !test15_v ? 0x10 : 0 },
+};