aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/semantics.c8
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-53094-1.C2
-rw-r--r--gcc/testsuite/g++.dg/ext/vector24.C8
5 files changed, 27 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6a04e58..9262813 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2013-07-09 Marc Glisse <marc.glisse@inria.fr>
+ PR c++/53094
+ * semantics.c (cxx_eval_bit_field_ref): Handle VECTOR_CST.
+
+2013-07-09 Marc Glisse <marc.glisse@inria.fr>
+
PR c++/53000
* call.c (build_conditional_expr_1): Preserve xvalues.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 0a6c775..c9a292e 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7197,7 +7197,9 @@ cxx_eval_bit_field_ref (const constexpr_call *call, tree t,
return t;
/* Don't VERIFY_CONSTANT here; we only want to check that we got a
CONSTRUCTOR. */
- if (!*non_constant_p && TREE_CODE (whole) != CONSTRUCTOR)
+ if (!*non_constant_p
+ && TREE_CODE (whole) != VECTOR_CST
+ && TREE_CODE (whole) != CONSTRUCTOR)
{
if (!allow_non_constant)
error ("%qE is not a constant expression", orig_whole);
@@ -7206,6 +7208,10 @@ cxx_eval_bit_field_ref (const constexpr_call *call, tree t,
if (*non_constant_p)
return t;
+ if (TREE_CODE (whole) == VECTOR_CST)
+ return fold_ternary (BIT_FIELD_REF, TREE_TYPE (t), whole,
+ TREE_OPERAND (t, 1), TREE_OPERAND (t, 2));
+
start = TREE_OPERAND (t, 2);
istart = tree_low_cst (start, 0);
isize = tree_low_cst (TREE_OPERAND (t, 1), 0);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 573d78a..a9b8829 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2013-07-09 Marc Glisse <marc.glisse@inria.fr>
+ PR c++/53094
+ * g++.dg/cpp0x/constexpr-53094-1.C: Adjust.
+ * g++.dg/ext/vector24.C: New testcase.
+
+2013-07-09 Marc Glisse <marc.glisse@inria.fr>
+
PR c++/53000
* g++.dg/cpp0x/decltype17.C: Adjust.
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-1.C
index c24ff60..e49023d 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-1.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-53094-1.C
@@ -3,4 +3,4 @@
typedef float __attribute__ ((vector_size (4 * sizeof (float)))) V4;
constexpr V4 v = { 1, 1, 1, 0 };
-constexpr V4 r = v[0] + v; // { dg-bogus "not a constant expression" "" { xfail *-*-* } }
+constexpr V4 r = v[0] + v;
diff --git a/gcc/testsuite/g++.dg/ext/vector24.C b/gcc/testsuite/g++.dg/ext/vector24.C
new file mode 100644
index 0000000..3eca7fb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/vector24.C
@@ -0,0 +1,8 @@
+// { dg-do compile { target c++11 } }
+
+typedef long vec __attribute__((vector_size(2*sizeof(long))));
+constexpr vec v = { 33, 42 };
+constexpr auto l0 = v[0];
+constexpr auto l1 = v[1];
+static_assert(l0==33,"Fail");
+static_assert(l1==42,"Fail");