[PATCH] D40895: Ignore pointers to incomplete types when diagnosing misaligned addresses
This revision was automatically updated to reflect the committed changes. Closed by commit rL320017: Ignore pointers to incomplete types when diagnosing misaligned addresses (authored by rogfer01). Changed prior to commit: https://reviews.llvm.org/D40895?vs=125718=125901#toc Repository: rL LLVM https://reviews.llvm.org/D40895 Files: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/SemaCXX/address-packed.cpp Index: cfe/trunk/lib/Sema/SemaChecking.cpp === --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -12399,8 +12399,9 @@ MisalignedMember(Op)); if (MA != MisalignedMembers.end() && (T->isIntegerType() || - (T->isPointerType() && -Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment))) + (T->isPointerType() && (T->getPointeeType()->isIncompleteType() || + Context.getTypeAlignInChars( + T->getPointeeType()) <= MA->Alignment MisalignedMembers.erase(MA); } } Index: cfe/trunk/test/SemaCXX/address-packed.cpp === --- cfe/trunk/test/SemaCXX/address-packed.cpp +++ cfe/trunk/test/SemaCXX/address-packed.cpp @@ -112,3 +112,12 @@ S s3; s3.get(); // expected-note {{in instantiation of member function 'S::get'}} } + +// PR35509 +typedef long L1; +struct Incomplete; +struct S2 { + L1 d; + Incomplete *e() const; +} __attribute__((packed)); +Incomplete *S2::e() const { return (Incomplete *) } // no-warning Index: cfe/trunk/lib/Sema/SemaChecking.cpp === --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -12399,8 +12399,9 @@ MisalignedMember(Op)); if (MA != MisalignedMembers.end() && (T->isIntegerType() || - (T->isPointerType() && -Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment))) + (T->isPointerType() && (T->getPointeeType()->isIncompleteType() || + Context.getTypeAlignInChars( + T->getPointeeType()) <= MA->Alignment MisalignedMembers.erase(MA); } } Index: cfe/trunk/test/SemaCXX/address-packed.cpp === --- cfe/trunk/test/SemaCXX/address-packed.cpp +++ cfe/trunk/test/SemaCXX/address-packed.cpp @@ -112,3 +112,12 @@ S s3; s3.get(); // expected-note {{in instantiation of member function 'S::get'}} } + +// PR35509 +typedef long L1; +struct Incomplete; +struct S2 { + L1 d; + Incomplete *e() const; +} __attribute__((packed)); +Incomplete *S2::e() const { return (Incomplete *) } // no-warning ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D40895: Ignore pointers to incomplete types when diagnosing misaligned addresses
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM, thank you! https://reviews.llvm.org/D40895 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D40895: Ignore pointers to incomplete types when diagnosing misaligned addresses
rogfer01 created this revision. This is a fix for PR35509 in which we crash because we attempt to compute the alignment of an incomplete type. https://reviews.llvm.org/D40895 Files: lib/Sema/SemaChecking.cpp test/SemaCXX/address-packed.cpp Index: test/SemaCXX/address-packed.cpp === --- test/SemaCXX/address-packed.cpp +++ test/SemaCXX/address-packed.cpp @@ -112,3 +112,12 @@ S s3; s3.get(); // expected-note {{in instantiation of member function 'S::get'}} } + +// PR35509 +typedef long L1; +struct Incomplete; +struct S2 { + L1 d; + Incomplete *e() const; +} __attribute__((packed)); +Incomplete *S2::e() const { return (Incomplete *) } // no-warning Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -12453,8 +12453,9 @@ MisalignedMember(Op)); if (MA != MisalignedMembers.end() && (T->isIntegerType() || - (T->isPointerType() && -Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment))) + (T->isPointerType() && (T->getPointeeType()->isIncompleteType() || + Context.getTypeAlignInChars( + T->getPointeeType()) <= MA->Alignment MisalignedMembers.erase(MA); } } Index: test/SemaCXX/address-packed.cpp === --- test/SemaCXX/address-packed.cpp +++ test/SemaCXX/address-packed.cpp @@ -112,3 +112,12 @@ S s3; s3.get(); // expected-note {{in instantiation of member function 'S::get'}} } + +// PR35509 +typedef long L1; +struct Incomplete; +struct S2 { + L1 d; + Incomplete *e() const; +} __attribute__((packed)); +Incomplete *S2::e() const { return (Incomplete *) } // no-warning Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -12453,8 +12453,9 @@ MisalignedMember(Op)); if (MA != MisalignedMembers.end() && (T->isIntegerType() || - (T->isPointerType() && -Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment))) + (T->isPointerType() && (T->getPointeeType()->isIncompleteType() || + Context.getTypeAlignInChars( + T->getPointeeType()) <= MA->Alignment MisalignedMembers.erase(MA); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits