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 | 29eb47bd685d65d824e1c8fa303b8a1e8c6af39b (patch) | |
tree | ca920493e0ca1c43f34cb720c96b835288c29920 /clang/lib/AST/ASTContext.cpp | |
parent | ef200db4fd1313050dca45d71469c82ba02037e0 (diff) | |
download | bcm5719-llvm-29eb47bd685d65d824e1c8fa303b8a1e8c6af39b.tar.gz bcm5719-llvm-29eb47bd685d65d824e1c8fa303b8a1e8c6af39b.zip |
Fix PR9253, allowing attribute(aligned) to reduce the alignment of
a typedef.
llvm-svn: 126059
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 94f3b337275..7da2f348439 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/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; } |