diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-01 08:12:08 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-01 08:12:08 +0000 |
commit | 848e1f19605a1769f28f5f08a37999c4043ae33b (patch) | |
tree | 2c7009338101c4c8c9f2640a0a0e34e3c6b3f4e0 /clang/lib/Sema/SemaDecl.cpp | |
parent | 4349f6963eead14e67ebb0cbe0042778be683484 (diff) | |
download | bcm5719-llvm-848e1f19605a1769f28f5f08a37999c4043ae33b.tar.gz bcm5719-llvm-848e1f19605a1769f28f5f08a37999c4043ae33b.zip |
Implement [dcl.align]p5 and C11 6.7.5/4: alignas cannot underalign.
Also support alignas(0), which C++11 and C11 require us to ignore.
llvm-svn: 174157
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 834041c65c0..4404c6f9a0e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4611,6 +4611,9 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, // Handle attributes prior to checking for duplicates in MergeVarDecl ProcessDeclAttributes(S, NewVD, D); + if (NewVD->hasAttrs()) + CheckAlignasUnderalignment(NewVD); + if (getLangOpts().CUDA) { // CUDA B.2.5: "__shared__ and __constant__ variables have implied static // storage [duration]." @@ -10158,10 +10161,14 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, // FIXME: We need to pass in the attributes given an AST // representation, not a parser representation. - if (D) + if (D) { // FIXME: What to pass instead of TUScope? ProcessDeclAttributes(TUScope, NewFD, *D); + if (NewFD->hasAttrs()) + CheckAlignasUnderalignment(NewFD); + } + // In auto-retain/release, infer strong retension for fields of // retainable type. if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewFD)) @@ -10680,6 +10687,8 @@ void Sema::ActOnFields(Scope* S, if (!Completed) Record->completeDefinition(); + if (Record->hasAttrs()) + CheckAlignasUnderalignment(Record); } else { ObjCIvarDecl **ClsFields = reinterpret_cast<ObjCIvarDecl**>(RecFields.data()); @@ -11427,6 +11436,10 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, DeclsInPrototypeScope.push_back(Enum); CheckForDuplicateEnumValues(*this, Elements, NumElements, Enum, EnumType); + + // Now that the enum type is defined, ensure it's not been underaligned. + if (Enum->hasAttrs()) + CheckAlignasUnderalignment(Enum); } Decl *Sema::ActOnFileScopeAsmDecl(Expr *expr, |