someone thought all the bits would be value bits in this case.
Also fix the wording of the warning -- it claimed that the width of 'bool' is
8, which is not correct; the width is 1 bit, whereas the size is 8 bits in our
implementation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248435
91177308-0d34-0410-b5e6-
96231b3b80d8
"anonymous bit-field has negative width (%0)">;
def err_bitfield_has_zero_width : Error<"named bit-field %0 has zero width">;
def err_bitfield_width_exceeds_type_width : Error<
- "width of bit-field %0 (%1 bits) exceeds width of its type (%2 bit%s2)">;
+ "width of bit-field %0 (%1 bits) exceeds %select{width|size}2 "
+ "of its type (%3 bit%s3)">;
def err_anon_bitfield_width_exceeds_type_width : Error<
- "width of anonymous bit-field (%0 bits) exceeds width of its type "
- "(%1 bit%s1)">;
+ "width of anonymous bit-field (%0 bits) exceeds %select{width|size}1 "
+ "of its type (%2 bit%s2)">;
def err_incorrect_number_of_vector_initializers : Error<
"number of elements must be either one or match the size of the vector">;
CStdConstraintViolation ? TypeWidth : TypeStorageSize;
if (FieldName)
return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
- << FieldName << (unsigned)Value.getZExtValue() << DiagWidth;
+ << FieldName << (unsigned)Value.getZExtValue()
+ << !CStdConstraintViolation << DiagWidth;
return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_width)
- << (unsigned)Value.getZExtValue() << DiagWidth;
+ << (unsigned)Value.getZExtValue() << !CStdConstraintViolation
+ << DiagWidth;
}
- if (BitfieldIsOverwide) {
+ // Warn on types where the user might conceivably expect to get all
+ // specified bits as value bits: that's all integral types other than
+ // 'bool'.
+ if (BitfieldIsOverwide && !FieldTy->isBooleanType()) {
if (FieldName)
Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
<< FieldName << (unsigned)Value.getZExtValue()
struct S13 { // expected-warning {{padding size of 'S13' with 6 bits to alignment boundary}}
char c;
- bool b : 10; // expected-warning {{width of bit-field 'b' (10 bits) exceeds the width of its type}}
+ bool b : 10;
};
// The warnings are emitted when the layout of the structs is computed, so we have to use them.
bool b : 1;
unsigned u : 5;
int n : 5;
- bool b2 : 3; // expected-warning {{exceeds the width of its type}}
+ bool b2 : 3;
unsigned u2 : 74; // expected-warning {{exceeds the width of its type}}
int n2 : 81; // expected-warning {{exceeds the width of its type}}
};
// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only -mms-bitfields -verify %s 2>&1
struct A {
- char a : 9; // expected-error{{width of bit-field 'a' (9 bits) exceeds width of its type (8 bits)}}
- int b : 33; // expected-error{{width of bit-field 'b' (33 bits) exceeds width of its type (32 bits)}}
- bool c : 9; // expected-error{{width of bit-field 'c' (9 bits) exceeds width of its type (8 bits)}}
- bool d : 3; // expected-warning{{width of bit-field 'd' (3 bits) exceeds the width of its type; value will be truncated to 1 bit}}
+ char a : 9; // expected-error{{width of bit-field 'a' (9 bits) exceeds size of its type (8 bits)}}
+ int b : 33; // expected-error{{width of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
+ bool c : 9; // expected-error{{width of bit-field 'c' (9 bits) exceeds size of its type (8 bits)}}
+ bool d : 3;
};
int a[sizeof(A) == 1 ? 1 : -1];