aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2009-12-30 21:28:45 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2009-12-30 21:28:45 +0000
commitd3ae6c2aa243ddbfad69d9decb459a4fa45519cc (patch)
tree3a957a9cf0bc7ad075c1b21b01621d3751c9e85b /gcc/c-decl.c
parent7417f6c0bd77d7cc05b6b051efa0c60987825f90 (diff)
downloadgcc-d3ae6c2aa243ddbfad69d9decb459a4fa45519cc.zip
gcc-d3ae6c2aa243ddbfad69d9decb459a4fa45519cc.tar.gz
gcc-d3ae6c2aa243ddbfad69d9decb459a4fa45519cc.tar.bz2
re PR c/42439 (Linux kernel BUILD_BUG_ON() broke)
PR c/42439 * c-decl.c (check_bitfield_type_and_width): Only pedwarn if pedantic for bit-field width not an integer constant expression but folding to one. testsuite: * gcc.dg/bitfld-19.c, gcc.dg/bitfld-20.c, gcc.dg/bitfld-21.c: New tests. From-SVN: r155526
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 49a530c..0655197 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -4570,14 +4570,26 @@ check_bitfield_type_and_width (tree *type, tree *width, tree orig_name)
/* Detect and ignore out of range field width and process valid
field widths. */
- if (!INTEGRAL_TYPE_P (TREE_TYPE (*width))
- || TREE_CODE (*width) != INTEGER_CST)
+ if (!INTEGRAL_TYPE_P (TREE_TYPE (*width)))
{
error ("bit-field %qs width not an integer constant", name);
*width = integer_one_node;
}
else
{
+ if (TREE_CODE (*width) != INTEGER_CST)
+ {
+ *width = c_fully_fold (*width, false, NULL);
+ if (TREE_CODE (*width) == INTEGER_CST)
+ pedwarn (input_location, OPT_pedantic,
+ "bit-field %qs width not an integer constant expression",
+ name);
+ }
+ if (TREE_CODE (*width) != INTEGER_CST)
+ {
+ error ("bit-field %qs width not an integer constant", name);
+ *width = integer_one_node;
+ }
constant_expression_warning (*width);
if (tree_int_cst_sgn (*width) < 0)
{