Explorar el Código

We're in a constant context in the ConstantEmitter.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348029 91177308-0d34-0410-b5e6-96231b3b80d8
Bill Wendling hace 6 años
padre
commit
14f7dacb88
Se han modificado 2 ficheros con 13 adiciones y 1 borrados
  1. 2 1
      lib/CodeGen/CGExprConstant.cpp
  2. 11 0
      test/CodeGen/builtin-constant-p.c

+ 2 - 1
lib/CodeGen/CGExprConstant.cpp

@@ -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)

+ 11 - 0
test/CodeGen/builtin-constant-p.c

@@ -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 },
+};