From 399093276c9af10ab1afe5740f11fc90eed7ae63 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Tue, 15 Apr 2014 20:12:41 +0000 Subject: AST: Respect alignment attributes on typedef'd arrays 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. llvm-svn: 206317 --- clang/lib/AST/ASTContext.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/lib/AST/ASTContext.cpp') diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 0f3809d538d..8a60bebd57a 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1322,7 +1322,9 @@ CharUnits ASTContext::getDeclAlign(const Decl *D, bool ForAlignof) const { 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())); -- cgit v1.2.3