aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa.c
diff options
context:
space:
mode:
authorJoseph Myers <jsm@polyomino.org.uk>2004-07-08 09:45:05 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2004-07-08 09:45:05 +0100
commitbc15d0efe4230e2f3636dc5255c331232211fb44 (patch)
tree69763a66482d42b14599835106ea027f80e7499e /gcc/tree-ssa.c
parent942e59391c7a8ff8d57439229877257eb62b2eb0 (diff)
downloadgcc-bc15d0efe4230e2f3636dc5255c331232211fb44.zip
gcc-bc15d0efe4230e2f3636dc5255c331232211fb44.tar.gz
gcc-bc15d0efe4230e2f3636dc5255c331232211fb44.tar.bz2
re PR c/2511 (-pedantic not warning about bitfield overflow)
2004-07-08 Joseph S. Myers <jsm@polyomino.org.uk> Neil Booth <neil@daikokuya.co.uk> PR c/2511 PR c/3325 * c-decl.c (finish_struct): Ensure bit-fields are given the correct type. * c-common.c (c_common_signed_or_unsigned_type): For C, require the precision to match as well as the mode. * expr.c (reduce_to_bit_field_precision): New function. (expand_expr_real_1): Reduce expressions of bit-field type to proper precision. * langhooks.h (reduce_bit_field_operations): New hook. * langhooks-def.h (LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS): Define. * c-lang.c, objc/objc-lang.c (LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS): Define. * objc/objc-act.c (check_ivars): Convert types to bit-field types before checking. * tree.c (build_nonstandard_integer_type): New function. * tree.h (build_nonstandard_integer_type): New prototype. * tree-ssa.c (tree_ssa_useless_type_conversion_1): Don't treat conversions between integer and boolean types as useless. testsuite: * gcc.c-torture/execute/bitfld-1.x: Remove. * gcc.c-torture/execute/bitfld-3.c: New test. * gcc.dg/bitfld-2.c: Remove XFAILs. Co-Authored-By: Neil Booth <neil@daikokuya.co.uk> From-SVN: r84279
Diffstat (limited to 'gcc/tree-ssa.c')
-rw-r--r--gcc/tree-ssa.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 3ab7ac2..ad1c174 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -572,17 +572,22 @@ tree_ssa_useless_type_conversion_1 (tree outer_type, tree inner_type)
/* If both the inner and outer types are integral types, then the
conversion is not necessary if they have the same mode and
- signedness and precision. Note that type _Bool can have size of
- 4 (only happens on powerpc-darwin right now but can happen on any
- target that defines BOOL_TYPE_SIZE to be INT_TYPE_SIZE) and a
- precision of 1 while unsigned int is the same expect for a
- precision of 4 so testing of precision is necessary. */
+ signedness and precision, and both or neither are boolean. Some
+ code assumes an invariant that boolean types stay boolean and do
+ not become 1-bit bit-field types. Note that types with precision
+ not using all bits of the mode (such as bit-field types in C)
+ mean that testing of precision is necessary. */
else if (INTEGRAL_TYPE_P (inner_type)
&& INTEGRAL_TYPE_P (outer_type)
&& TYPE_MODE (inner_type) == TYPE_MODE (outer_type)
&& TYPE_UNSIGNED (inner_type) == TYPE_UNSIGNED (outer_type)
&& TYPE_PRECISION (inner_type) == TYPE_PRECISION (outer_type))
- return true;
+ {
+ bool first_boolean = (TREE_CODE (inner_type) == BOOLEAN_TYPE);
+ bool second_boolean = (TREE_CODE (outer_type) == BOOLEAN_TYPE);
+ if (first_boolean == second_boolean)
+ return true;
+ }
/* Recurse for complex types. */
else if (TREE_CODE (inner_type) == COMPLEX_TYPE