Index: test/CodeGenCXX/alignof.cpp
===================================================================
--- test/CodeGenCXX/alignof.cpp	(revision 0)
+++ test/CodeGenCXX/alignof.cpp	(revision 0)
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+// Test that the alignment of a empty direct base class is correctly
+// inherited by the derived class.
+
+struct A {
+} __attribute__ ((aligned(16)));
+
+struct B1 : public A {
+};
+
+struct B2 : public A {
+} __attribute__ ((aligned(2)));
+
+struct B3 : public A {
+} __attribute__ ((aligned(4)));
+
+struct B4 : public A {
+} __attribute__ ((aligned(8)));
+
+struct B5 : public A {
+} __attribute__ ((aligned(16)));
+
+struct B6 : public A {
+} __attribute__ ((aligned(32)));
+
+int test1() {
+  return __alignof(A);
+}
+
+// CHECK: @_Z5test1v
+// CHECK: ret i32 16
+
+int test2() {
+  return __alignof(B1);
+}
+
+// CHECK: @_Z5test2v
+// CHECK: ret i32 16
+
+int test3() {
+  return __alignof(B2);
+}
+
+// CHECK: @_Z5test3v
+// CHECK: ret i32 16
+
+int test4() {
+  return __alignof(B3);
+}
+
+// CHECK: @_Z5test4v
+// CHECK: ret i32 16
+
+int test5() {
+  return __alignof(B4);
+}
+
+// CHECK: @_Z5test5v
+// CHECK: ret i32 16
+
+int test6() {
+  return __alignof(B5);
+}
+
+// CHECK: @_Z5test6v
+// CHECK: ret i32 16
+
+int test7() {
+  return __alignof(B6);
+}
+
+// CHECK: @_Z5test7v
+// CHECK: ret i32 32
+
Index: lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- lib/AST/RecordLayoutBuilder.cpp	(revision 186158)
+++ lib/AST/RecordLayoutBuilder.cpp	(working copy)
@@ -1532,18 +1532,20 @@
     }
   }
   
+  CharUnits UnpackedBaseAlign = Layout.getNonVirtualAlign();
+  CharUnits BaseAlign = (Packed) ? CharUnits::One() : UnpackedBaseAlign;
+ 
   // If we have an empty base class, try to place it at offset 0.
   if (Base->Class->isEmpty() &&
       (!HasExternalLayout || Offset == CharUnits::Zero()) &&
       EmptySubobjects->CanPlaceBaseAtOffset(Base, CharUnits::Zero())) {
     setSize(std::max(getSize(), Layout.getSize()));
+    // Remember max struct/class alignment.
+    UpdateAlignment(BaseAlign, UnpackedBaseAlign);
 
     return CharUnits::Zero();
   }
 
-  CharUnits UnpackedBaseAlign = Layout.getNonVirtualAlign();
-  CharUnits BaseAlign = (Packed) ? CharUnits::One() : UnpackedBaseAlign;
-
   // The maximum field alignment overrides base align.
   if (!MaxFieldAlignment.isZero()) {
     BaseAlign = std::min(BaseAlign, MaxFieldAlignment);
