pt.c (tsubst_decl): Handle DECL_VALUE_EXPR on reference.
authorJason Merrill <jason@redhat.com>
Fri, 17 Jun 2011 20:07:20 +0000 (16:07 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 17 Jun 2011 20:07:20 +0000 (16:07 -0400)
* pt.c (tsubst_decl): Handle DECL_VALUE_EXPR on reference.
* decl.c (check_initializer): Handle DECL_VALUE_EXPR_P.

From-SVN: r175153

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/pt.c

index 010f1ddaa4f355f0eba658371ffdad6d42c05ae9..81b332de8479ad9da6cf8b292c91b71ca8ff3f5f 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-17  Jason Merrill  <jason@redhat.com>
 
+       * pt.c (tsubst_decl): Handle DECL_VALUE_EXPR on reference.
+       * decl.c (check_initializer): Handle DECL_VALUE_EXPR_P.
+
        * semantics.c (finish_non_static_data_member): Preserve dereference
        in template.
 
index 0584cd8f6f71fe7188ad7c10c54c94fc009e390a..9f62ea34e12bfcbcd034ff847da2d0d9f2f519c2 100644 (file)
@@ -5387,6 +5387,14 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
      type.  */
   TREE_TYPE (decl) = type = complete_type (TREE_TYPE (decl));
 
+  if (DECL_HAS_VALUE_EXPR_P (decl))
+    {
+      /* A variable with DECL_HAS_VALUE_EXPR_P set is just a placeholder,
+        it doesn't have storage to be initialized.  */
+      gcc_assert (init == NULL_TREE);
+      return NULL_TREE;
+    }
+
   if (type == error_mark_node)
     /* We will have already complained.  */
     return NULL_TREE;
index 1008b3be399a810ec871ec5fe4bef8757b2d2434..308aff7bc4809bcac07bf7af6bccef94d5001cd3 100644 (file)
@@ -10061,6 +10061,11 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
                tree ve = DECL_VALUE_EXPR (t);
                ve = tsubst_expr (ve, args, complain, in_decl,
                                  /*constant_expression_p=*/false);
+               if (REFERENCE_REF_P (ve))
+                 {
+                   gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);
+                   ve = TREE_OPERAND (ve, 0);
+                 }
                SET_DECL_VALUE_EXPR (r, ve);
              }
          }