[PATCH] D40895: Ignore pointers to incomplete types when diagnosing misaligned addresses

Roger Ferrer Ibanez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 7 01:24:27 PST 2017


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&id=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<float> s3;
   s3.get(); // expected-note {{in instantiation of member function 'S<float>::get'}}
 }
+
+// PR35509
+typedef long L1;
+struct Incomplete;
+struct S2 {
+  L1 d;
+  Incomplete *e() const;
+} __attribute__((packed));
+Incomplete *S2::e() const { return (Incomplete *)&d; } // no-warning


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40895.125901.patch
Type: text/x-patch
Size: 1269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171207/41aa1da4/attachment.bin>


More information about the cfe-commits mailing list