aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2007-12-19 07:19:40 +0000
committerAnders Carlsson <andersca@mac.com>2007-12-19 07:19:40 +0000
commit78aaae9a611d53803fc645de83b297a06f581306 (patch)
tree35b632f81d02761cea791df82b068db4da489e1b
parentf8d1080f597dec91c932074994909ef6fc88e10b (diff)
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
-rw-r--r--Sema/Sema.h2
-rw-r--r--Sema/SemaDecl.cpp22
2 files changed, 23 insertions, 1 deletions
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<Expr *>(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;
+ }
+}