When instantiating an array that has an alignment attribute on it, we
were looking through the array type and only considering the element
type for the resulting alignment. We need to make sure we take the
array's requirements into account too.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206317
91177308-0d34-0410-b5e6-
96231b3b80d8
Align = std::max(Align, Target->getLargeArrayAlign());
}
- // Walk through any array types while we're at it.
+ // Keep track of extra alignment requirements on the array itself, then
+ // work with the element type.
+ Align = std::max(Align, getPreferredTypeAlign(T.getTypePtr()));
T = getBaseElementType(arrayType);
}
Align = std::max(Align, getPreferredTypeAlign(T.getTypePtr()));
struct E e;
char e1[__alignof__(e) == 2 ?: -1] = {0};
char e2[__alignof__(e.member) == 2 ?: -1] = {0};
+
+typedef char overaligned_char __attribute__((aligned(16)));
+typedef overaligned_char array_with_overaligned_char[11];
+typedef char array_with_align_attr[11] __attribute__((aligned(16)));
+
+char f0[__alignof__(array_with_overaligned_char) == 16 ? 1 : -1] = { 0 };
+char f1[__alignof__(array_with_align_attr) == 16 ? 1 : -1] = { 0 };
+array_with_overaligned_char F2;
+char f2[__alignof__(F2) == 16 ? 1 : -1] = { 0 };
+array_with_align_attr F3;
+char f3[__alignof__(F3) == 16 ? 1 : -1] = { 0 };