aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1992-09-11 08:52:38 +0000
committerRichard Stallman <rms@gnu.org>1992-09-11 08:52:38 +0000
commit2d7243898e983c8df7abc4b51cfe9ef23327f0a9 (patch)
tree97ee7c0bd7ec4402577d48d4d0b0292bb4d44993 /gcc
parent1f0c5cc9cf4410e18aec390311de0e7b2956b5da (diff)
downloadgcc-2d7243898e983c8df7abc4b51cfe9ef23327f0a9.zip
gcc-2d7243898e983c8df7abc4b51cfe9ef23327f0a9.tar.gz
gcc-2d7243898e983c8df7abc4b51cfe9ef23327f0a9.tar.bz2
(finish_struct): Don't assume that a target integer
fits in a HOST_WIDE_INT when checking bit-field widths. From-SVN: r2105
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-decl.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 6a50539..59d0c52 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -4826,23 +4826,23 @@ finish_struct (t, fieldlist)
/* Detect and ignore out of range field width. */
if (DECL_INITIAL (x))
{
- register int width = TREE_INT_CST_LOW (DECL_INITIAL (x));
+ unsigned HOST_WIDE_INT width = TREE_INT_CST_LOW (DECL_INITIAL (x));
- if (width < 0)
+ if (tree_int_cst_lt (DECL_INITIAL (x), integer_zero_node))
{
DECL_INITIAL (x) = NULL;
error_with_decl (x, "negative width in bit-field `%s'");
}
- else if (width == 0 && DECL_NAME (x) != 0)
+ else if (TREE_INT_CST_HIGH (DECL_INITIAL (x)) != 0
+ || width > TYPE_PRECISION (TREE_TYPE (x)))
{
- error_with_decl (x, "zero width for bit-field `%s'");
DECL_INITIAL (x) = NULL;
+ pedwarn_with_decl (x, "width of `%s' exceeds its type");
}
- else if (width > TYPE_PRECISION (TREE_TYPE (x))
- || TREE_INT_CST_HIGH (DECL_INITIAL (x)) != 0)
+ else if (width == 0 && DECL_NAME (x) != 0)
{
+ error_with_decl (x, "zero width for bit-field `%s'");
DECL_INITIAL (x) = NULL;
- pedwarn_with_decl (x, "width of `%s' exceeds its type");
}
}