re PR c++/53094 (constexpr vector subscripting)

2013-07-09  Marc Glisse  <marc.glisse@inria.fr>

	PR c++/53094
gcc/cp/
	* semantics.c (cxx_eval_bit_field_ref): Handle VECTOR_CST.

gcc/testsuite/
	* g++.dg/cpp0x/constexpr-53094-1.C: Adjust.
	* g++.dg/ext/vector24.C: New testcase.

From-SVN: r200822
This commit is contained in:
Marc Glisse 2013-07-09 17:58:36 +02:00 committed by Marc Glisse
parent 76c7bf65e8
commit 40e0364c55
5 changed files with 27 additions and 2 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -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);

View File

@ -1,3 +1,9 @@
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

View File

@ -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;

View File

@ -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");