Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ std::unique_ptr<BugReport> checkFieldImpl(const FieldDecl *D, BugReporter &BR,
const BugType &BT) {
QualType T = D->getType();

// If the parent struct is explicitly marked as packed, then don't emit a
// diagnostic, as this layout is likely intentional.
if (D->getParent()->hasAttr<PackedAttr>())
return nullptr;

ASTContext &ASTCtx = BR.getContext();
uint64_t Offset = ASTCtx.getFieldOffset(D) / 8;
if (Offset > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ struct R1 {
int c[2];
char a[0x1000]; // no warn
} f3good __attribute__((aligned(8)));
struct __attribute__((packed)) {
char c;
char a[0x1000]; // no warn
} f4good;
} s2;
} s1;

Expand Down