Skip to content

Commit 2e955c0

Browse files
vabridgerseinvbri
andauthored
Revert "[Sema] Add check for bitfield assignments to integral types" (#68963)
This reverts commit 47e3626. This change broke some arm8/arm7 build bots because int and void * have the same size. Co-authored-by: einvbri <[email protected]>
1 parent f54dc7b commit 2e955c0

File tree

5 files changed

+1
-54
lines changed

5 files changed

+1
-54
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ New Compiler Flags
185185
the preprocessed text to the output. This can greatly reduce the size of the
186186
preprocessed output, which can be helpful when trying to reduce a test case.
187187

188-
* ``-Wbitfield-conversion`` was added to detect assignments of integral
189-
types to a bitfield that may change the value.
190-
191188
Deprecated Compiler Flags
192189
-------------------------
193190

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def SingleBitBitFieldConstantConversion :
5353
def BitFieldConstantConversion : DiagGroup<"bitfield-constant-conversion",
5454
[SingleBitBitFieldConstantConversion]>;
5555
def BitFieldEnumConversion : DiagGroup<"bitfield-enum-conversion">;
56-
def BitFieldConversion : DiagGroup<"bitfield-conversion">;
5756
def BitFieldWidth : DiagGroup<"bitfield-width">;
5857
def CompoundTokenSplitByMacro : DiagGroup<"compound-token-split-by-macro">;
5958
def CompoundTokenSplitBySpace : DiagGroup<"compound-token-split-by-space">;
@@ -934,7 +933,6 @@ def Conversion : DiagGroup<"conversion",
934933
ConstantConversion,
935934
EnumConversion,
936935
BitFieldEnumConversion,
937-
BitFieldConversion,
938936
FloatConversion,
939937
Shorten64To32,
940938
IntConversion,

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6171,9 +6171,6 @@ def warn_signed_bitfield_enum_conversion : Warning<
61716171
"signed bit-field %0 needs an extra bit to represent the largest positive "
61726172
"enumerators of %1">,
61736173
InGroup<BitFieldEnumConversion>, DefaultIgnore;
6174-
def warn_bitfield_too_small_for_integral_type : Warning<
6175-
"conversion from %2 (%3 bits) to bit-field %0 (%1 bits) may change value">,
6176-
InGroup<BitFieldConversion>, DefaultIgnore;
61776174
def note_change_bitfield_sign : Note<
61786175
"consider making the bitfield type %select{unsigned|signed}0">;
61796176

clang/lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14298,18 +14298,6 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,
1429814298
S.Diag(WidthExpr->getExprLoc(), diag::note_widen_bitfield)
1429914299
<< BitsNeeded << ED << WidthExpr->getSourceRange();
1430014300
}
14301-
} else if (OriginalInit->getType()->isIntegralType(S.Context)) {
14302-
IntRange LikelySourceRange =
14303-
GetExprRange(S.Context, Init, S.isConstantEvaluatedContext(),
14304-
/*Approximate=*/true);
14305-
14306-
if (LikelySourceRange.Width > FieldWidth) {
14307-
Expr *WidthExpr = Bitfield->getBitWidth();
14308-
S.Diag(InitLoc, diag::warn_bitfield_too_small_for_integral_type)
14309-
<< Bitfield << FieldWidth << OriginalInit->getType()
14310-
<< LikelySourceRange.Width;
14311-
S.Diag(WidthExpr->getExprLoc(), diag::note_declared_at);
14312-
}
1431314301
}
1431414302

1431514303
return false;
@@ -15207,6 +15195,7 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
1520715195

1520815196
if (LikelySourceRange.Width > TargetRange.Width) {
1520915197
// If the source is a constant, use a default-on diagnostic.
15198+
// TODO: this should happen for bitfield stores, too.
1521015199
Expr::EvalResult Result;
1521115200
if (E->EvaluateAsInt(Result, S.Context, Expr::SE_AllowSideEffects,
1521215201
S.isConstantEvaluatedContext())) {

clang/test/SemaCXX/bitfield-width.c

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)