Index: test/Sema/align-x86.c
===================================================================
--- test/Sema/align-x86.c	(revision 96880)
+++ test/Sema/align-x86.c	(working copy)
@@ -12,3 +12,9 @@
 _Complex double g3;
 short chk1[__alignof__(g3) == 8 ? 1 : -1]; 
 short chk2[__alignof__(_Complex double) == 8 ? 1 : -1];
+
+// PR6362
+struct __attribute__((packed)) {unsigned int a} g4;
+short chk1[__alignof__(g4) == 1 ? 1 : -1];
+short chk2[__alignof__(g4.a) == 1 ? 1 : -1];
+
Index: lib/AST/ASTContext.cpp
===================================================================
--- lib/AST/ASTContext.cpp	(revision 96880)
+++ lib/AST/ASTContext.cpp	(working copy)
@@ -563,6 +563,12 @@
 
       Align = std::max(Align, getPreferredTypeAlign(T.getTypePtr()));
     }
+    if (const FieldDecl *FD = dyn_cast<FieldDecl>(VD)) {
+      // In the case of a field in a packed struct, we want the MINIMUM
+      // of the alignment of the field and the alignment of the struct.
+      Align = std::min(Align,
+        getPreferredTypeAlign(FD->getParent()->getTypeForDecl()));
+    }
   }
 
   return CharUnits::fromQuantity(Align / Target.getCharWidth());
