c-decl.c (check_bitfield_type_and_width): Require bit-field width to have integer type.
* c-decl.c (check_bitfield_type_and_width): Require bit-field width to have integer type. (build_enumerator): Require enumerator value to have integer type. testsuite: * gcc.dg/bitfld-14.c, gcc.dg/enum3.c: New tests. From-SVN: r96755
This commit is contained in:
parent
57e4253f85
commit
411ffa02ae
@ -1,3 +1,9 @@
|
||||
2005-03-20 Joseph S. Myers <joseph@codesourcery.com>
|
||||
|
||||
* c-decl.c (check_bitfield_type_and_width): Require bit-field
|
||||
width to have integer type.
|
||||
(build_enumerator): Require enumerator value to have integer type.
|
||||
|
||||
2005-03-19 Joseph S. Myers <joseph@codesourcery.com>
|
||||
|
||||
* doc/extend.texi (__builtin_inf): Move statement about INFINITY
|
||||
|
@ -3642,7 +3642,8 @@ check_bitfield_type_and_width (tree *type, tree *width, const char *orig_name)
|
||||
|
||||
/* Detect and ignore out of range field width and process valid
|
||||
field widths. */
|
||||
if (TREE_CODE (*width) != INTEGER_CST)
|
||||
if (!INTEGRAL_TYPE_P (TREE_TYPE (*width))
|
||||
|| TREE_CODE (*width) != INTEGER_CST)
|
||||
{
|
||||
error ("bit-field %qs width not an integer constant", name);
|
||||
*width = integer_one_node;
|
||||
@ -5633,7 +5634,8 @@ build_enumerator (tree name, tree value)
|
||||
undeclared identifier) - just ignore the value expression. */
|
||||
if (value == error_mark_node)
|
||||
value = 0;
|
||||
else if (TREE_CODE (value) != INTEGER_CST)
|
||||
else if (!INTEGRAL_TYPE_P (TREE_TYPE (value))
|
||||
|| TREE_CODE (value) != INTEGER_CST)
|
||||
{
|
||||
error ("enumerator value for %qE is not an integer constant", name);
|
||||
value = 0;
|
||||
|
@ -1,3 +1,7 @@
|
||||
2005-03-20 Joseph S. Myers <joseph@codesourcery.com>
|
||||
|
||||
* gcc.dg/bitfld-14.c, gcc.dg/enum3.c: New tests.
|
||||
|
||||
2005-03-19 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
|
||||
|
||||
PR fortran/18525
|
||||
|
11
gcc/testsuite/gcc.dg/bitfld-14.c
Normal file
11
gcc/testsuite/gcc.dg/bitfld-14.c
Normal file
@ -0,0 +1,11 @@
|
||||
/* Test for non-integer bit-field widths. */
|
||||
/* Origin: Joseph Myers <joseph@codesourcery.com> */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "" } */
|
||||
|
||||
enum e { E, F };
|
||||
struct s {
|
||||
int a : (void *)4; /* { dg-error "error: bit-field 'a' width not an integer constant" } */
|
||||
int b : (enum e)F;
|
||||
int c : (_Bool)1;
|
||||
};
|
11
gcc/testsuite/gcc.dg/enum3.c
Normal file
11
gcc/testsuite/gcc.dg/enum3.c
Normal file
@ -0,0 +1,11 @@
|
||||
/* Test for non-integer enum values. */
|
||||
/* Origin: Joseph Myers <joseph@codesourcery.com> */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "" } */
|
||||
|
||||
enum e { E, F };
|
||||
enum e2 {
|
||||
E1 = (void *)4, /* { dg-error "error: enumerator value for 'E1' is not an integer constant" } */
|
||||
E2 = (enum e)F,
|
||||
E3 = (_Bool)1
|
||||
};
|
Loading…
Reference in New Issue
Block a user