This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Bit-field patch, part 1
- From: Richard Henderson <rth at redhat dot com>
- To: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 18 Dec 2003 13:06:01 -0800
- Subject: Re: Bit-field patch, part 1
- References: <Pine.LNX.4.58.0312170025310.31156@digraph.polyomino.org.uk>
On Wed, Dec 17, 2003 at 12:26:14AM +0000, Joseph S. Myers wrote:
> It should also be sufficient for RTH's patch (always warning for enum
> bit-fields with -pedantic) not to require additional complexity to
> save the pedantic setting.
Indeed it is, thank you. I've committed the following after
bootstrap and check on alphaev67-linux.
r~
* c-decl.c (check_bitfield_type_and_width): Remove enum special
case suppression of pedwarn.
* system.h (ENUM_BITFIELD): Use __extension__.
(CHAR_BITFIELD): Likewise.
cp/
* cp-tree.h (struct lang_type_header): Remove __extension__.
testsuite/
* gcc.dg/bitfld-1.c: Expect warnings for enum bitfields.
Index: gcc/c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.460
diff -c -p -d -u -r1.460 c-decl.c
--- gcc/c-decl.c 17 Dec 2003 00:25:17 -0000 1.460
+++ gcc/c-decl.c 18 Dec 2003 20:59:33 -0000
@@ -3268,10 +3268,7 @@ check_bitfield_type_and_width (tree *typ
if (pedantic
&& type_mv != integer_type_node
&& type_mv != unsigned_type_node
- && type_mv != boolean_type_node
- /* Accept an enum that's equivalent to int or unsigned int. */
- && (TREE_CODE (*type) != ENUMERAL_TYPE
- || TYPE_PRECISION (*type) != TYPE_PRECISION (integer_type_node)))
+ && type_mv != boolean_type_node)
pedwarn ("type of bit-field `%s' is a GCC extension", name);
if (type_mv == boolean_type_node)
Index: gcc/system.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/system.h,v
retrieving revision 1.176
diff -c -p -d -u -r1.176 system.h
--- gcc/system.h 18 Dec 2003 05:50:43 -0000 1.176
+++ gcc/system.h 18 Dec 2003 20:59:33 -0000
@@ -490,8 +490,8 @@ extern int snprintf (char *, size_t, con
FIXME: provide a complete autoconf test for buggy enum bitfields. */
#if (GCC_VERSION > 2000)
-#define ENUM_BITFIELD(TYPE) enum TYPE
-#define CHAR_BITFIELD unsigned char
+#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE
+#define CHAR_BITFIELD __extension__ unsigned char
#else
#define ENUM_BITFIELD(TYPE) unsigned int
#define CHAR_BITFIELD unsigned int
Index: gcc/cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.939
diff -c -p -d -u -r1.939 cp-tree.h
--- gcc/cp/cp-tree.h 12 Dec 2003 18:22:22 -0000 1.939
+++ gcc/cp/cp-tree.h 18 Dec 2003 20:59:33 -0000
@@ -1017,7 +1017,7 @@ enum languages { lang_c, lang_cplusplus,
/* This is a few header flags for 'struct lang_type'. Actually,
all but the first are used only for lang_type_class; they
are put in this structure to save space. */
-__extension__ struct lang_type_header GTY(())
+struct lang_type_header GTY(())
{
CHAR_BITFIELD is_lang_type_class : 1;
Index: gcc/testsuite/gcc.dg/bitfld-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/bitfld-1.c,v
retrieving revision 1.2
diff -c -p -d -u -r1.2 bitfld-1.c
--- gcc/testsuite/gcc.dg/bitfld-1.c 2 Feb 2002 00:14:39 -0000 1.2
+++ gcc/testsuite/gcc.dg/bitfld-1.c 18 Dec 2003 20:59:33 -0000
@@ -25,6 +25,7 @@ struct bf1
unsigned long g: 5; /* { dg-warning "GCC extension|ISO C" } */
ui h: 5;
enum foo i: 2; /* { dg-error "narrower" } */
- enum foo j: 3;
+ /* { dg-warning "GCC extension|ISO C" "extension" { target *-*-* } 27 } */
+ enum foo j: 3; /* { dg-warning "GCC extension|ISO C" } */
unsigned int k: 256; /* { dg-error "exceeds its type" } */
};