diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-19 22:55:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-19 22:55:41 +0000 |
commit | c1de52de64725945e5ae87e6f99ddedf161856e5 (patch) | |
tree | b990f1f5f7d3218991074f89b15765772a77192c /lib/AST/ASTContext.cpp | |
parent | 3e026e323f1bd820fb9c880b1db951c87df94bb4 (diff) |
Fix PR9253, allowing attribute(aligned) to reduce the alignment of
a typedef.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 94f3b33727..7da2f34843 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -882,7 +882,13 @@ ASTContext::getTypeInfo(const Type *T) const { const TypedefDecl *Typedef = cast<TypedefType>(T)->getDecl(); std::pair<uint64_t, unsigned> Info = getTypeInfo(Typedef->getUnderlyingType().getTypePtr()); - Align = std::max(Typedef->getMaxAlignment(), Info.second); + // If the typedef has an aligned attribute on it, it overrides any computed + // alignment we have. This violates the GCC documentation (which says that + // attribute(aligned) can only round up) but matches its implementation. + if (unsigned AttrAlign = Typedef->getMaxAlignment()) + Align = AttrAlign; + else + Align = Info.second; Width = Info.first; break; } |