diff options
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 34 |
1 files changed, 15 insertions, 19 deletions
@@ -10197,32 +10197,26 @@ widest_int_cst_value (const_tree x) return val; } -/* If TYPE is an integral type, return an equivalent type which is - unsigned iff UNSIGNEDP is true. If TYPE is not an integral type, - return TYPE itself. */ +/* If TYPE is an integral or pointer type, return an integer type with + the same precision which is unsigned iff UNSIGNEDP is true, or itself + if TYPE is already an integer type of signedness UNSIGNEDP. */ tree signed_or_unsigned_type_for (int unsignedp, tree type) { - tree t = type; - if (POINTER_TYPE_P (type)) - { - /* If the pointer points to the normal address space, use the - size_type_node. Otherwise use an appropriate size for the pointer - based on the named address space it points to. */ - if (!TYPE_ADDR_SPACE (TREE_TYPE (t))) - t = size_type_node; - else - return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp); - } + if (TREE_CODE (type) == INTEGER_TYPE && TYPE_UNSIGNED (type) == unsignedp) + return type; - if (!INTEGRAL_TYPE_P (t) || TYPE_UNSIGNED (t) == unsignedp) - return t; + if (!INTEGRAL_TYPE_P (type) + && !POINTER_TYPE_P (type)) + return NULL_TREE; - return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp); + return build_nonstandard_integer_type (TYPE_PRECISION (type), unsignedp); } -/* Returns unsigned variant of TYPE. */ +/* If TYPE is an integral or pointer type, return an integer type with + the same precision which is unsigned, or itself if TYPE is already an + unsigned integer type. */ tree unsigned_type_for (tree type) @@ -10230,7 +10224,9 @@ unsigned_type_for (tree type) return signed_or_unsigned_type_for (1, type); } -/* Returns signed variant of TYPE. */ +/* If TYPE is an integral or pointer type, return an integer type with + the same precision which is signed, or itself if TYPE is already a + signed integer type. */ tree signed_type_for (tree type) |