Implement #pragma pack use in structure packing. The general approach
is to encode the state of the #pragma pack stack as an attribute when
the structure is declared. 

 - Extend PackedAttr to take an alignment (in bits), and reuse for
   both __attribute__((packed)) (which takes no argument, instead
   packing tightly (to "minimize the memory required") and for #pragma
   pack (which allows specification of the maximum alignment in
   bytes). __attribute__((packed)) is just encoded as Alignment=1.

   This conflates two related but different mechanisms, but it didn't
   seem worth another attribute.

 - I have attempted to follow the MSVC semantics as opposed to the gcc
   ones, since if I understand correctly #pragma pack originated with
   MSVC. The semantics are generally equivalent except when the stack
   is altered during the definition of a structure; its not clear if
   anyone does this in practice. See testcase if curious.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57623 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 3ab0c91..5c04bf0 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -256,7 +256,7 @@
   }
   
   if (TagDecl *TD = dyn_cast<TagDecl>(d))
-    TD->addAttr(new PackedAttr());
+    TD->addAttr(new PackedAttr(1));
   else if (FieldDecl *FD = dyn_cast<FieldDecl>(d)) {
     // If the alignment is less than or equal to 8 bits, the packed attribute
     // has no effect.
@@ -266,7 +266,7 @@
              diag::warn_attribute_ignored_for_field_of_type,
              Attr.getName()->getName(), FD->getType().getAsString());
     else
-      FD->addAttr(new PackedAttr());
+      FD->addAttr(new PackedAttr(1));
   } else
     S.Diag(Attr.getLoc(), diag::warn_attribute_ignored,
            Attr.getName()->getName());