This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] -funsigned-bitfields breaks parsing
- To: ehr at listworks dot com
- Subject: Re: [PATCH] -funsigned-bitfields breaks parsing
- From: mark at codesourcery dot com
- Date: Thu, 03 Jun 1999 10:08:40 -0700
- Cc: egcs-patches at egcs dot cygnus dot com
- Organization: CodeSourcery, LLC
- References: <08fc01bead06$e4b52b80$65c8c8c8@ehrpc.listworks.com>
I checked in the following patch instead of the one provided by Eric;
it's a bit more maintainable.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
1999-06-03 Mark Mitchell <mark@codesourcery.com>
* decl.c (grokdeclarator): Don't treat arbitrary types as unsigned
just because flag_signed_bitfields is false.
Index: testsuite/g++.old-deja/g++.other/bitfld2.C
===================================================================
RCS file: bitfld2.C
diff -N bitfld2.C
--- /dev/null Sat Dec 5 20:30:03 1998
+++ bitfld2.C Thu Jun 3 09:46:33 1999
@@ -0,0 +1,8 @@
+// Origin: Mark Mitchell <mark@codesourcery.com>
+// Special g++ Options: -funsigned-bitfields
+
+typedef int i[4];
+
+struct S {
+ i j:12; // ERROR - array type as bitfield
+};
Index: cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.368
diff -u -p -r1.368 decl.c
--- decl.c 1999/05/30 14:41:33 1.368
+++ decl.c 1999/06/03 16:46:56
@@ -9921,14 +9921,24 @@ grokdeclarator (declarator, declspecs, d
/* Decide whether an integer type is signed or not.
Optionally treat bitfields as signed by default. */
if (RIDBIT_SETP (RID_UNSIGNED, specbits)
- || (bitfield && ! flag_signed_bitfields
- && (explicit_int || defaulted_int || explicit_char
- /* A typedef for plain `int' without `signed'
- can be controlled just like plain `int'. */
- || ! (typedef_decl != NULL_TREE
- && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
- && TREE_CODE (type) != ENUMERAL_TYPE
- && RIDBIT_NOTSETP (RID_SIGNED, specbits)))
+ /* [class.bit]
+
+ It is implementation-defined whether a plain (neither
+ explicitly signed or unsigned) char, short, int, or long
+ bit-field is signed or unsigned.
+
+ Naturally, we extend this to long long as well. Note that
+ this does not include wchar_t. */
+ || (bitfield && !flag_signed_bitfields
+ && RIDBIT_NOTSETP (RID_SIGNED, specbits)
+ /* A typedef for plain `int' without `signed' can be
+ controlled just like plain `int', but a typedef for
+ `signed int' cannot be so controlled. */
+ && !(typedef_decl
+ && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
+ && (TREE_CODE (type) == INTEGER_TYPE
+ || TREE_CODE (type) == CHAR_TYPE)
+ && !same_type_p (TYPE_MAIN_VARIANT (type), wchar_type_node))
{
if (longlong)
type = long_long_unsigned_type_node;