re PR c++/54581 (decltype and opaque vector types)

2012-09-19  Marc Glisse  <marc.glisse@inria.fr>

	PR c++/54581

gcc/cp/
	* semantics.c (finish_decltype_type): Make vectors not opaque.

gcc/testsuite/
	* g++.dg/cpp0x/decltype-54581.C: New testcase.

From-SVN: r191500
This commit is contained in:
Marc Glisse 2012-09-19 22:45:03 +02:00 committed by Marc Glisse
parent b7f401de87
commit 7cea661c88
4 changed files with 43 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2012-09-19 Marc Glisse <marc.glisse@inria.fr>
PR c++/54581
* semantics.c (finish_decltype_type): Make vectors not opaque.
2012-09-17 Jason Merrill <jason@redhat.com>
PR c++/54575

View File

@ -5312,6 +5312,11 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
cp_lvalue_kind clk = lvalue_kind (expr);
type = unlowered_expr_type (expr);
gcc_assert (TREE_CODE (type) != REFERENCE_TYPE);
/* For vector types, pick a non-opaque variant. */
if (TREE_CODE (type) == VECTOR_TYPE)
type = strip_typedefs (type);
if (clk != clk_none && !(clk & clk_class))
type = cp_build_reference_type (type, (clk & clk_rvalueref));
}

View File

@ -1,3 +1,8 @@
2012-09-19 Marc Glisse <marc.glisse@inria.fr>
PR c++/54581
* g++.dg/cpp0x/decltype-54581.C: New testcase.
2012-09-19 Steve Ellcey <sellcey@mips.com>
* gcc.target/mips/pr37362.c: Add mips*-mti-elf exception.

View File

@ -0,0 +1,28 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu++11 -Wall" } */
typedef float v4f __attribute__((vector_size(4*sizeof(float))));
template <class T> void eat (T&&) {}
void test1 ()
{
v4f x = {0,1,2,3};
typedef decltype (x < x) v4i;
v4i y = {4,5,6,7}; // v4i is not opaque
eat (y);
}
template<class V>
void test2 ()
{
V x = {0,1,2,3};
typedef decltype (x < x) v4i;
v4i y = {4,5,6,7}; // v4i is not opaque
eat (y);
}
int main(){
test1();
test2<v4f>();
}