aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2024-05-19 04:29:11 -0700
committerVitaly Buka <vitalybuka@google.com>2024-05-19 05:44:40 -0700
commited9007d0d219726db01f211e9c9ab72fbfe4ecb1 (patch)
treebbc39067b1d4f0e9037ea5a85be561f9affa0157 /clang/lib
parent7273ad123850a7b44c0625d098ebb49153bf855a (diff)
downloadllvm-ed9007d0d219726db01f211e9c9ab72fbfe4ecb1.zip
llvm-ed9007d0d219726db01f211e9c9ab72fbfe4ecb1.tar.gz
llvm-ed9007d0d219726db01f211e9c9ab72fbfe4ecb1.tar.bz2
Revert "[Bounds-Safety] Temporarily relax a `counted_by` attribute restriction on flexible array members"
Together with 0ec3b972e58bcbcdc1bebe1696ea37f2931287c3 breaks https://lab.llvm.org/buildbot/#/builders/5/builds/43403 Issue #92687 This reverts commit cef6387e52578366c2332275dad88b9953b55336.
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp17
1 files changed, 2 insertions, 15 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index e816ea3..c8b7163 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -8687,7 +8687,6 @@ static bool CheckCountedByAttrOnField(
// Note: The `Decl::isFlexibleArrayMemberLike` check earlier on means
// only `PointeeTy->isStructureTypeWithFlexibleArrayMember()` is reachable
// when `FieldTy->isArrayType()`.
- bool ShouldWarn = false;
if (PointeeTy->isIncompleteType()) {
InvalidTypeKind = CountedByInvalidPointeeTypeKind::INCOMPLETE;
} else if (PointeeTy->isSizelessType()) {
@@ -8695,25 +8694,13 @@ static bool CheckCountedByAttrOnField(
} else if (PointeeTy->isFunctionType()) {
InvalidTypeKind = CountedByInvalidPointeeTypeKind::FUNCTION;
} else if (PointeeTy->isStructureTypeWithFlexibleArrayMember()) {
- if (FieldTy->isArrayType()) {
- // This is a workaround for the Linux kernel that has already adopted
- // `counted_by` on a FAM where the pointee is a struct with a FAM. This
- // should be an error because computing the bounds of the array cannot be
- // done correctly without manually traversing every struct object in the
- // array at runtime. To allow the code to be built this error is
- // downgraded to a warning.
- ShouldWarn = true;
- }
InvalidTypeKind = CountedByInvalidPointeeTypeKind::FLEXIBLE_ARRAY_MEMBER;
}
if (InvalidTypeKind != CountedByInvalidPointeeTypeKind::VALID) {
- unsigned DiagID = ShouldWarn
- ? diag::warn_counted_by_attr_elt_type_unknown_size
- : diag::err_counted_by_attr_pointee_unknown_size;
- S.Diag(FD->getBeginLoc(), DiagID)
+ S.Diag(FD->getBeginLoc(), diag::err_counted_by_attr_pointee_unknown_size)
<< SelectPtrOrArr << PointeeTy << (int)InvalidTypeKind
- << (ShouldWarn ? 1 : 0) << FD->getSourceRange();
+ << FD->getSourceRange();
return true;
}