Commit 2d724389 by Richard Stallman

(finish_struct): Don't assume that a target integer

fits in a HOST_WIDE_INT when checking bit-field widths.

From-SVN: r2105
parent 1f0c5cc9
...@@ -4826,23 +4826,23 @@ finish_struct (t, fieldlist) ...@@ -4826,23 +4826,23 @@ finish_struct (t, fieldlist)
/* Detect and ignore out of range field width. */ /* Detect and ignore out of range field width. */
if (DECL_INITIAL (x)) 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; DECL_INITIAL (x) = NULL;
error_with_decl (x, "negative width in bit-field `%s'"); 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; DECL_INITIAL (x) = NULL;
pedwarn_with_decl (x, "width of `%s' exceeds its type");
} }
else if (width > TYPE_PRECISION (TREE_TYPE (x)) else if (width == 0 && DECL_NAME (x) != 0)
|| TREE_INT_CST_HIGH (DECL_INITIAL (x)) != 0)
{ {
error_with_decl (x, "zero width for bit-field `%s'");
DECL_INITIAL (x) = NULL; DECL_INITIAL (x) = NULL;
pedwarn_with_decl (x, "width of `%s' exceeds its type");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment