OSDN Git Service

2004-11-24 Paolo Bonzini <bonzini@gnu.org>
authorbonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Nov 2004 10:06:54 +0000 (10:06 +0000)
committerbonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Nov 2004 10:06:54 +0000 (10:06 +0000)
PR c++/16882

* tree.c (make_vector_type): Move qualifiers to the vector type,
use the inner type's main variant and build a main variant for
the vector type if necessary.
(type_hash_eq): Check a vector type's TYPE_VECTOR_SUBPARTS.

cp:
2004-11-24  Paolo Bonzini  <bonzini@gnu.org>

PR c++/16882

* call.c (standard_conversion): Move check for conversions between
vector pointers...
* typeck.c (ptr_reasonably_similar): ... here.

testsuite:
2004-11-24  Paolo Bonzini  <bonzini@gnu.org>

PR c++/16882

* g++.dg/conversion/simd1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91142 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/conversion/simd1.C [new file with mode: 0644]
gcc/tree.c

index ada5b33..4ca7cf5 100644 (file)
@@ -1,3 +1,12 @@
+2004-11-24  Paolo Bonzini  <bonzini@gnu.org>
+
+       PR c++/16882
+
+       * tree.c (make_vector_type): Move qualifiers to the vector type,
+       use the inner type's main variant and build a main variant for
+       the vector type if necessary.
+       (type_hash_eq): Check a vector type's TYPE_VECTOR_SUBPARTS.
+
 2004-11-24  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * target.h (late_rtl_prologue_epilogue): Remove.
index a8ed1ae..4f9c1d8 100644 (file)
@@ -1,3 +1,11 @@
+2004-11-24  Paolo Bonzini  <bonzini@gnu.org>
+
+       PR c++/16882
+
+       * call.c (standard_conversion): Move check for conversions between
+       vector pointers...
+       * typeck.c (ptr_reasonably_similar): ... here.
+
 2004-11-23  Ben Elliston  <bje@au.ibm.com>
 
        * cp-tree.h (context_as_string): Remove extern.
index 613d0d4..c67b16f 100644 (file)
@@ -652,11 +652,6 @@ standard_conversion (tree to, tree from, tree expr)
   if ((tcode == POINTER_TYPE || TYPE_PTR_TO_MEMBER_P (to))
       && expr && null_ptr_cst_p (expr))
     conv = build_conv (ck_std, to, conv);
-  else if (tcode == POINTER_TYPE && fcode == POINTER_TYPE
-          && TREE_CODE (TREE_TYPE (to)) == VECTOR_TYPE
-          && TREE_CODE (TREE_TYPE (from)) == VECTOR_TYPE
-          && vector_types_convertible_p (TREE_TYPE (to), TREE_TYPE (from)))
-    conv = build_conv (ck_std, to, conv);
   else if ((tcode == INTEGER_TYPE && fcode == POINTER_TYPE)
           || (tcode == POINTER_TYPE && fcode == INTEGER_TYPE))
     {
index 4caf051..60f03c9 100644 (file)
@@ -6425,6 +6425,10 @@ ptr_reasonably_similar (tree to, tree from)
                        COMPARE_BASE | COMPARE_DERIVED))
        continue;
 
+      if (TREE_CODE (to) == VECTOR_TYPE
+         && vector_types_convertible_p (to, from))
+       return 1;
+
       if (TREE_CODE (to) == INTEGER_TYPE
          && TYPE_PRECISION (to) == TYPE_PRECISION (from))
        return 1;
index c6fcacb..6c75fd8 100644 (file)
@@ -1,3 +1,9 @@
+2004-11-24  Paolo Bonzini  <bonzini@gnu.org>
+
+       PR c++/16882
+
+       * g++.dg/conversion/simd1.C: New test.
+
 2004-11-23  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * lib/target-libpath.exp: New file defining set_ld_library_path_env_vars
diff --git a/gcc/testsuite/g++.dg/conversion/simd1.C b/gcc/testsuite/g++.dg/conversion/simd1.C
new file mode 100644 (file)
index 0000000..a1ae3a7
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+
+/* Test overload resolution of vector types.
+   From Janis Johnson and Paolo Bonzini, based on PR/16882 */
+
+#define vector __attribute__((vector_size(16)))
+
+vector signed int vld (int a1, const vector signed int *a2) { return *a2; } /* { dg-error "near match" } */
+vector signed short vld (int a1, const vector signed short *a2) { return *a2; } /* { dg-error "near match" } */
+
+extern int i;
+extern vector signed short vss;
+extern vector signed char *vscp;
+extern vector signed short *vssp;
+extern const vector signed short *cvssp;
+
+void foo ()
+{
+  vss = vld(i, vscp);        /* { dg-error "no match" } */
+  vss = vld(i, vssp);
+  vss = vld(i, cvssp);
+}
index 32ec8a5..643f1de 100644 (file)
@@ -3437,11 +3437,13 @@ type_hash_eq (const void *va, const void *vb)
     {
     case VOID_TYPE:
     case COMPLEX_TYPE:
-    case VECTOR_TYPE:
     case POINTER_TYPE:
     case REFERENCE_TYPE:
       return 1;
 
+    case VECTOR_TYPE:
+      return TYPE_VECTOR_SUBPARTS (a->type) == TYPE_VECTOR_SUBPARTS (b->type);
+
     case ENUMERAL_TYPE:
       if (TYPE_VALUES (a->type) != TYPE_VALUES (b->type)
          && !(TYPE_VALUES (a->type)
@@ -5542,9 +5544,12 @@ make_vector_type (tree innertype, int nunits, enum machine_mode mode)
 {
   tree t = make_node (VECTOR_TYPE);
 
-  TREE_TYPE (t) = innertype;
+  TREE_TYPE (t) = TYPE_MAIN_VARIANT (innertype);
   TYPE_VECTOR_SUBPARTS (t) = nunits;
   TYPE_MODE (t) = mode;
+  TYPE_READONLY (t) = TYPE_READONLY (innertype);
+  TYPE_VOLATILE (t) = TYPE_VOLATILE (innertype);
+
   layout_type (t);
 
   {
@@ -5563,6 +5568,16 @@ make_vector_type (tree innertype, int nunits, enum machine_mode mode)
     TYPE_UID (rt) = TYPE_UID (t);
   }
 
+  /* Build our main variant, based on the main variant of the inner type.  */
+  if (TYPE_MAIN_VARIANT (innertype) != innertype)
+    {
+      tree innertype_main_variant = TYPE_MAIN_VARIANT (innertype);
+      unsigned int hash = TYPE_HASH (innertype_main_variant);
+      TYPE_MAIN_VARIANT (t)
+        = type_hash_canon (hash, make_vector_type (innertype_main_variant,
+                                                  nunits, mode));
+    }
+
   return t;
 }