[PATCH] Change uint*_type_node definition to make_or_reuse_type

Andreas Krebbel krebbel@linux.vnet.ibm.com
Wed Jun 5 12:26:00 GMT 2013


Hi,

I'm trying to implement a builtin with a uint64_t* argument type as
build_pointer_type (uint64_type_node).  Unfortunately this fails for a
simple case like:

uint64_t a;
__builtin_test (&a);

t.c:7:3: warning: passing argument 1 of ‘__builtin_test’ from incompatible pointer type [enabled by default]
   __builtin_test(&a);
   ^
t.c:7:3: note: expected ‘long unsigned int *’ but argument is of type ‘uint64_t *’

The problem is how the uint64_type_node is generated.  We just create
a new "unsigned long" data type which cannot be unified with the
existing in convert_for_assignment because its main_variant type just
points to itself.

Reusing the existing integer data types as a base this matches the
implementation in stdint.h and works fine for me.

The only other user appears to be the bswap64 builtin.  This keeps
working as before with that change.

Ok for mainline?

Bye,

-Andreas-

2013-06-05  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	* tree.c (build_common_tree_nodes): Create uint*_t type nodes with
	make_or_reuse_type.

---
 gcc/tree.c |    6 !!!!!!
 1 file changed, 6 modifications(!)

Index: gcc/tree.c
===================================================================
*** gcc/tree.c.orig
--- gcc/tree.c
*************** build_common_tree_nodes (bool signed_cha
*** 9550,9558 ****
    integer_ptr_type_node = build_pointer_type (integer_type_node);
  
    /* Fixed size integer types.  */
!   uint16_type_node = build_nonstandard_integer_type (16, true);
!   uint32_type_node = build_nonstandard_integer_type (32, true);
!   uint64_type_node = build_nonstandard_integer_type (64, true);
  
    /* Decimal float types. */
    dfloat32_type_node = make_node (REAL_TYPE);
--- 9550,9558 ----
    integer_ptr_type_node = build_pointer_type (integer_type_node);
  
    /* Fixed size integer types.  */
!   uint16_type_node = make_or_reuse_type (16, true);
!   uint32_type_node = make_or_reuse_type (32, true);
!   uint64_type_node = make_or_reuse_type (64, true);
  
    /* Decimal float types. */
    dfloat32_type_node = make_node (REAL_TYPE);



More information about the Gcc-patches mailing list