OSDN Git Service

PR c++/53839
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 13 Sep 2012 15:15:06 +0000 (15:15 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 13 Sep 2012 15:15:06 +0000 (15:15 +0000)
* semantics.c (cxx_eval_indirect_ref): If we aren't looking for an
address, make sure the value is constant.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@191266 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-temp1.C [new file with mode: 0644]

index 9243bf2..96cdf57 100644 (file)
@@ -1,5 +1,11 @@
 2012-09-13  Jason Merrill  <jason@redhat.com>
 
+       PR c++/53839
+       * semantics.c (cxx_eval_indirect_ref): If we aren't looking for an
+       address, make sure the value is constant.
+
+2012-09-13  Jason Merrill  <jason@redhat.com>
+
        PR c++/54511
        * pt.c (tsubst_decl) [VAR_DECL]: Handle DECL_ANON_UNION_VAR_P.
 
index 1dd1e32..a64c5b7 100644 (file)
@@ -7454,7 +7454,11 @@ cxx_eval_indirect_ref (const constexpr_call *call, tree t,
     }
 
   if (r == NULL_TREE)
-    return t;
+    {
+      if (!addr)
+       VERIFY_CONSTANT (t);
+      return t;
+    }
   return r;
 }
 
index e9ab7eb..ba9347d 100644 (file)
@@ -1,5 +1,10 @@
 2012-09-13  Jason Merrill  <jason@redhat.com>
 
+       PR c++/53839
+       * g++.dg/cpp0x/constexpr-temp1.C: New.
+
+2012-09-13  Jason Merrill  <jason@redhat.com>
+
        PR c++/54511
        * g++.dg/template/anonunion2.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-temp1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-temp1.C
new file mode 100644 (file)
index 0000000..d065436
--- /dev/null
@@ -0,0 +1,9 @@
+// { dg-do compile { target c++11 } }
+
+struct A { int i; };
+constexpr A f2 (const A& a) { return a; }
+constexpr int f1 (const A &a) { return f2(a).i; }
+A g(const A &a)
+{
+  return { f1(a) };
+}