20030505.c: New.

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.

From-SVN: r66495
This commit is contained in:
Aldy Hernandez 2003-05-05 19:21:10 +00:00 committed by Aldy Hernandez
parent 50b97e0f2b
commit 6035d635b5
4 changed files with 50 additions and 7 deletions

View 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

View 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))))
{

View 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

View File

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