aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2012-12-11 21:20:23 +0100
committerMarc Glisse <glisse@gcc.gnu.org>2012-12-11 20:20:23 +0000
commit4eab75dd128cec9fd5b1b011f992be6b69f7ee81 (patch)
tree0277ae7a99c17b3afc64d4b3af39811c76bdd446 /gcc/cp
parent759deff3ac0e0c8a7680dd106e05394ad219f84b (diff)
downloadgcc-4eab75dd128cec9fd5b1b011f992be6b69f7ee81.zip
gcc-4eab75dd128cec9fd5b1b011f992be6b69f7ee81.tar.gz
gcc-4eab75dd128cec9fd5b1b011f992be6b69f7ee81.tar.bz2
re PR c++/53094 (constexpr vector subscripting)
2012-12-11 Marc Glisse <marc.glisse@inria.fr> PR c++/53094 cp/ * tree.c (cp_tree_equal): Handle VECTOR_CST. * semantics.c (cxx_eval_bare_aggregate): Protect a dereference. Handle VECTOR_CST. testsuite/ * g++.dg/cpp0x/constexpr-53094-1.C: New testcase. * g++.dg/cpp0x/constexpr-53094-2.C: Likewise. * g++.dg/cpp0x/constexpr-53094-3.C: Likewise. From-SVN: r194421
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/semantics.c6
-rw-r--r--gcc/cp/tree.c3
3 files changed, 14 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2cd295b..5e75a14 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2012-12-11 Marc Glisse <marc.glisse@inria.fr>
+
+ PR c++/53094
+ * tree.c (cp_tree_equal): Handle VECTOR_CST.
+ * semantics.c (cxx_eval_bare_aggregate): Protect a dereference.
+ Handle VECTOR_CST.
+
2012-12-11 Jakub Jelinek <jakub@redhat.com>
PR c++/55643
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index ad33c65..f649399 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7123,7 +7123,7 @@ cxx_eval_bare_aggregate (const constexpr_call *call, tree t,
goto fail;
if (elt != ce->value)
changed = true;
- if (TREE_CODE (ce->index) == COMPONENT_REF)
+ if (ce->index && TREE_CODE (ce->index) == COMPONENT_REF)
{
/* This is an initialization of a vfield inside a base
subaggregate that we already initialized; push this
@@ -7131,7 +7131,7 @@ cxx_eval_bare_aggregate (const constexpr_call *call, tree t,
constructor_elt *inner = base_field_constructor_elt (n, ce->index);
inner->value = elt;
}
- else if (TREE_CODE (ce->index) == NOP_EXPR)
+ else if (ce->index && TREE_CODE (ce->index) == NOP_EXPR)
{
/* This is an initializer for an empty base; now that we've
checked that it's constant, we can ignore it. */
@@ -7148,6 +7148,8 @@ cxx_eval_bare_aggregate (const constexpr_call *call, tree t,
}
t = build_constructor (TREE_TYPE (t), n);
TREE_CONSTANT (t) = true;
+ if (TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
+ t = fold (t);
return t;
}
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 00fe53f..c430237 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2468,6 +2468,9 @@ cp_tree_equal (tree t1, tree t2)
return cp_tree_equal (TREE_REALPART (t1), TREE_REALPART (t2))
&& cp_tree_equal (TREE_IMAGPART (t1), TREE_IMAGPART (t2));
+ case VECTOR_CST:
+ return operand_equal_p (t1, t2, OEP_ONLY_CONST);
+
case CONSTRUCTOR:
/* We need to do this when determining whether or not two
non-type pointer to member function template arguments