OSDN Git Service

2003-05-05 Aldy Hernandez <aldyh@redhat.com>
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 May 2003 19:21:10 +0000 (19:21 +0000)
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 May 2003 19:21:10 +0000 (19:21 +0000)
        * testsuite/gcc.dg/20030505.c: New.

        * c-typeck.c (convert_for_assignment): Opaque pointers can
        interconvert.

        * config/rs6000/rs6000.c: New global opaque_p_V2SI_type_node.
        (rs6000_init_builtins): Initialize opaque_p_V2SI_type_node.
        (spe_init_builtins): Rename all pv2si_type_node to
        opaque_p_V2SI_type_node.
        Remove declaration of pv2si_type_node.
        (is_ev64_opaque_type): Accept opaque pointers.

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

gcc/ChangeLog
gcc/c-typeck.c
gcc/config/rs6000/rs6000.c
gcc/testsuite/gcc.dg/20030505.c [new file with mode: 0644]

index 4d765a3..a28796e 100644 (file)
@@ -1,3 +1,17 @@
+2003-05-05  Aldy Hernandez  <aldyh@redhat.com>
+
+        * testsuite/gcc.dg/20030505.c: New.
+
+        * c-typeck.c (convert_for_assignment): Opaque pointers can
+        interconvert.
+
+        * config/rs6000/rs6000.c: New global opaque_p_V2SI_type_node.
+        (rs6000_init_builtins): Initialize opaque_p_V2SI_type_node.
+        (spe_init_builtins): Rename all pv2si_type_node to
+        opaque_p_V2SI_type_node.
+        Remove declaration of pv2si_type_node.
+        (is_ev64_opaque_type): Accept opaque pointers.
+
 2003-05-05  Geoffrey Keating  <geoffk@apple.com>
 
        * toplev.c (check_global_declarations): Suppress not-used warning
index 92c64cd..23b7d2d 100644 (file)
@@ -4209,12 +4209,20 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
     {
       tree ttl = TREE_TYPE (type);
       tree ttr = TREE_TYPE (rhstype);
+      bool is_opaque_pointer;
+
+      /* Opaque pointers are treated like void pointers.  */
+      is_opaque_pointer = ((*targetm.vector_opaque_p) (type)
+                           || (*targetm.vector_opaque_p) (rhstype))
+        && TREE_CODE (ttl) == VECTOR_TYPE
+        && TREE_CODE (ttr) == VECTOR_TYPE;
 
       /* Any non-function converts to a [const][volatile] void *
         and vice versa; otherwise, targets must be the same.
         Meanwhile, the lhs target must have all the qualifiers of the rhs.  */
       if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
          || comp_target_types (type, rhstype, 0)
+         || is_opaque_pointer
          || (c_common_unsigned_type (TYPE_MAIN_VARIANT (ttl))
              == c_common_unsigned_type (TYPE_MAIN_VARIANT (ttr))))
        {
index 2f28301..695443a 100644 (file)
@@ -147,11 +147,10 @@ const char *rs6000_debug_name;
 int rs6000_debug_stack;                /* debug stack applications */
 int rs6000_debug_arg;          /* debug argument handling */
 
-/* A copy of V2SI_type_node to be used as an opaque type.  */
+/* Opaque types.  */
 static GTY(()) tree opaque_V2SI_type_node;
-
-/* Same, but for V2SF.  */
 static GTY(()) tree opaque_V2SF_type_node;
+static GTY(()) tree opaque_p_V2SI_type_node;
 
 const char *rs6000_traceback_name;
 static enum {
@@ -5645,6 +5644,7 @@ rs6000_init_builtins ()
 {
   opaque_V2SI_type_node = copy_node (V2SI_type_node);
   opaque_V2SF_type_node = copy_node (V2SF_type_node);
+  opaque_p_V2SI_type_node = build_pointer_type (opaque_V2SI_type_node);
 
   if (TARGET_SPE)
     spe_init_builtins ();
@@ -5689,7 +5689,6 @@ spe_init_builtins ()
   tree endlink = void_list_node;
   tree puint_type_node = build_pointer_type (unsigned_type_node);
   tree pushort_type_node = build_pointer_type (short_unsigned_type_node);
-  tree pv2si_type_node = build_pointer_type (opaque_V2SI_type_node);
   struct builtin_description *d;
   size_t i;
 
@@ -5746,7 +5745,7 @@ spe_init_builtins ()
   tree void_ftype_v2si_pv2si_int
     = build_function_type (void_type_node,
                           tree_cons (NULL_TREE, opaque_V2SI_type_node,
-                                     tree_cons (NULL_TREE, pv2si_type_node,
+                                     tree_cons (NULL_TREE, opaque_p_V2SI_type_node,
                                                 tree_cons (NULL_TREE,
                                                            integer_type_node,
                                                            endlink))));
@@ -5754,7 +5753,7 @@ spe_init_builtins ()
   tree void_ftype_v2si_pv2si_char
     = build_function_type (void_type_node,
                           tree_cons (NULL_TREE, opaque_V2SI_type_node,
-                                     tree_cons (NULL_TREE, pv2si_type_node,
+                                     tree_cons (NULL_TREE, opaque_p_V2SI_type_node,
                                                 tree_cons (NULL_TREE,
                                                            char_type_node,
                                                            endlink))));
@@ -5769,7 +5768,7 @@ spe_init_builtins ()
 
   tree v2si_ftype_pv2si_int
     = build_function_type (opaque_V2SI_type_node,
-                          tree_cons (NULL_TREE, pv2si_type_node,
+                          tree_cons (NULL_TREE, opaque_p_V2SI_type_node,
                                      tree_cons (NULL_TREE, integer_type_node,
                                                 endlink)));
 
@@ -14044,6 +14043,7 @@ is_ev64_opaque_type (type)
   return (TARGET_SPE
          && (type == opaque_V2SI_type_node
              || type == opaque_V2SF_type_node
+             || type == opaque_p_V2SI_type_node
              || (TREE_CODE (type) == VECTOR_TYPE
                  && TYPE_NAME (type)
                  && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
diff --git a/gcc/testsuite/gcc.dg/20030505.c b/gcc/testsuite/gcc.dg/20030505.c
new file mode 100644 (file)
index 0000000..1cd80a5
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile { target powerpc-eabi* } } */
+/* { dg-options "-W" } */
+
+#define __vector __attribute__((vector_size(8)))
+
+typedef float                   __vector __ev64_fs__;
+typedef int                     __vector __ev64_opaque__;
+
+__ev64_opaque__ *p1;
+__ev64_fs__ *p2;
+int *x;
+
+extern void f (__ev64_opaque__ *);
+
+int main ()
+{
+       f (x);  /* { dg-warning "incompatible pointer type" } */
+       f (p1);
+       f (p2);
+       return 0;
+}