]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/54581 (decltype and opaque vector types)
authorMarc Glisse <marc.glisse@inria.fr>
Wed, 19 Sep 2012 20:45:03 +0000 (22:45 +0200)
committerMarc Glisse <glisse@gcc.gnu.org>
Wed, 19 Sep 2012 20:45:03 +0000 (20:45 +0000)
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

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype-54581.C [new file with mode: 0644]

index 676c1669298c05cb29040db2b472d8c2b602bd65..0427a1975038851e196bc96e5bf17d0378e4182a 100644 (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
index db093e0b98da3678cc9983ab52a5e9bff2163d8e..1aa5a8b8b561a460f0317ad38c608e01c48d952e 100644 (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));
        }
index f02d15477e81942441286b1cc7e4e683bde0bd54..09c1d3fee7dd545aa022d66a1dc14db52fc707ab 100644 (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.
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-54581.C b/gcc/testsuite/g++.dg/cpp0x/decltype-54581.C
new file mode 100644 (file)
index 0000000..5747e5c
--- /dev/null
@@ -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>();
+}