aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-06-17 16:07:20 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-06-17 16:07:20 -0400
commitf05f61fd73568da443c330faaadfeecba45158d7 (patch)
tree965100083753d03a9f1f92b6fb414d0045bf7e9e
parent2516ccfe927c61a98bdd561eea90c7229a6a3cbc (diff)
downloadgcc-f05f61fd73568da443c330faaadfeecba45158d7.zip
gcc-f05f61fd73568da443c330faaadfeecba45158d7.tar.gz
gcc-f05f61fd73568da443c330faaadfeecba45158d7.tar.bz2
pt.c (tsubst_decl): Handle DECL_VALUE_EXPR on reference.
* pt.c (tsubst_decl): Handle DECL_VALUE_EXPR on reference. * decl.c (check_initializer): Handle DECL_VALUE_EXPR_P. From-SVN: r175153
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/decl.c8
-rw-r--r--gcc/cp/pt.c5
3 files changed, 16 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 010f1dd..81b332d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 0584cd8..9f62ea3 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 1008b3b..308aff7 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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);
}
}