[PATCH] Add support for -funsigned-bitfields

Richard Smith metafoo at gmail.com
Mon Jan 27 13:10:58 PST 2014


This patch is not quite correct. Given:

typedef int A;
typedef signed int B;
struct S { A a : 1; B b : 1; };

... -funsigned-bitfields should give 'a' an unsigned type and 'b' a signed
type.

In C++, this is non-conforming -- 'plain' bitfields are required to be
signed in C++, since otherwise you would get incoherent behavior inside
class templates -- and I'd like us to reject the flag in C++ mode unless
there's some strong compatibility argument.

In C99 onwards, this behavior is conforming but makes no sense in some
cases, since the same typedef can be redeclared with and without an
explicit 'signed' type specifier. We should diagnose such cases.

What is the motivation for allowing this?

On Mon Jan 27 2014 at 9:10:38 AM, Artyom Skrobov <Artyom.Skrobov at arm.com>
wrote:

> Hello,
>
> The attached patch adds the support for -funsigned-bitfields and
> -fsigned-bitfields command-line options, as available in GCC.
>
> Regarding the implementation: DeclSpec::TypeSpecSign for a bitfield was not
> accessible directly via the FieldDecl, so it took a bit of
> plumbing-through.
>
> OK to commit?_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140127/a660f738/attachment.html>


More information about the cfe-commits mailing list