diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-06-03 10:07:18 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-06-03 10:07:18 +0000 |
commit | b89c5a7b53874bf0fa55f53a8ebbf16cc23ed345 (patch) | |
tree | 27ab2a708784e1828c99304a32675bbcd8d0ee29 | |
parent | 5403593a4401fca1ef78e3926effc637ae435369 (diff) | |
download | gcc-b89c5a7b53874bf0fa55f53a8ebbf16cc23ed345.zip gcc-b89c5a7b53874bf0fa55f53a8ebbf16cc23ed345.tar.gz gcc-b89c5a7b53874bf0fa55f53a8ebbf16cc23ed345.tar.bz2 |
decl.c (grokdeclarator): Don't treat arbitrary types as unsigned just because flag_signed_bitfields is false.
* decl.c (grokdeclarator): Don't treat arbitrary types as unsigned
just because flag_signed_bitfields is false.
From-SVN: r27328
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl.c | 26 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/bitfld2.C | 8 |
3 files changed, 31 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 49ea8bc..b7f4289 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +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. + 1999-06-03 Nathan Sidwell <nathan@acm.org> * semantics.c (begin_class_definition): Update the struct's diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ac9933c..1592a64 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9921,14 +9921,24 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) /* 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; diff --git a/gcc/testsuite/g++.old-deja/g++.other/bitfld2.C b/gcc/testsuite/g++.old-deja/g++.other/bitfld2.C new file mode 100644 index 0000000..466c5ce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/bitfld2.C @@ -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 +}; |