From 78aaae9a611d53803fc645de83b297a06f581306 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 19 Dec 2007 07:19:40 +0000 Subject: [PATCH] Fix an embarassing typo and add some very limited support for the aligned attribute. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45195 91177308-0d34-0410-b5e6-96231b3b80d8 --- Sema/Sema.h | 2 ++ Sema/SemaDecl.cpp | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Sema/Sema.h b/Sema/Sema.h index e78bf308f7..3722ec2560 100644 --- a/Sema/Sema.h +++ b/Sema/Sema.h @@ -250,6 +250,8 @@ private: QualType HandleVectorTypeAttribute(QualType curType, AttributeList *rawAttr); void HandleOCUVectorTypeAttribute(TypedefDecl *d, AttributeList *rawAttr); + void HandleAlignedAttribute(Decl *d, AttributeList *rawAttr); + /// CheckProtocolMethodDefs - This routine checks unimpletented methods /// Declared in protocol, and those referenced by it. void CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl, diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 12f7d7a388..f5115dbaab 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -1678,7 +1678,10 @@ void Sema::HandleDeclAttribute(Decl *New, AttributeList *rawAttr) { else Diag(rawAttr->getAttributeLoc(), diag::err_typecheck_ocu_vector_not_typedef); + } else if (attrLen == 7 && !memcmp(attrName, "aligned", 7)) { + HandleAlignedAttribute(New, rawAttr); } + // FIXME: add other attributes... } @@ -1697,7 +1700,7 @@ void Sema::HandleDeclAttributes(Decl *New, AttributeList *declspec_prefix, void Sema::HandleOCUVectorTypeAttribute(TypedefDecl *tDecl, AttributeList *rawAttr) { QualType curType = tDecl->getUnderlyingType(); - // check the attribute arugments. + // check the attribute arguments. if (rawAttr->getNumArgs() != 1) { Diag(rawAttr->getAttributeLoc(), diag::err_attribute_wrong_number_arguments, std::string("1")); @@ -1795,3 +1798,20 @@ QualType Sema::HandleVectorTypeAttribute(QualType curType, return Context.getVectorType(curType, vectorSize/typeSize); } +void Sema::HandleAlignedAttribute(Decl *d, AttributeList *rawAttr) +{ + // check the attribute arguments. + if (rawAttr->getNumArgs() != 1) { + Diag(rawAttr->getAttributeLoc(), diag::err_attribute_wrong_number_arguments, + std::string("1")); + return; + } + + Expr *alignmentExpr = static_cast(rawAttr->getArg(0)); + llvm::APSInt alignment(32); + if (!alignmentExpr->isIntegerConstantExpr(alignment, Context)) { + Diag(rawAttr->getAttributeLoc(), diag::err_attribute_vector_size_not_int, + alignmentExpr->getSourceRange()); + return; + } +} -- 2.40.0