diff options
author | Anders Carlsson <andersca@mac.com> | 2009-03-16 18:19:21 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-03-16 18:19:21 +0000 |
commit | f257b619059e05906c4d93f3dc134857f818f44c (patch) | |
tree | c33f1ea8c51939ae54386eca11ffd403903b96cd | |
parent | c31a0cee75c08b09d1feb051bf71336b370c1330 (diff) |
Check signedness of bitfield sizes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67045 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | test/Sema/bitfield.c | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 51b2b853a8..d34a8e7111 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3363,7 +3363,7 @@ bool Sema::VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, if (Value == 0 && FieldName) return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName; - if (Value.isNegative()) + if (Value.isSigned() && Value.isNegative()) return Diag(FieldLoc, diag::err_bitfield_has_negative_width) << FieldName << Value.toString(10); diff --git a/test/Sema/bitfield.c b/test/Sema/bitfield.c index 7a70fe8de8..0a658c5c33 100644 --- a/test/Sema/bitfield.c +++ b/test/Sema/bitfield.c @@ -17,5 +17,7 @@ struct a { // PR3607 enum e0 f : 1; // expected-error {{field has incomplete type 'enum e0'}} + + int g : (_Bool)1; }; |