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
diff --git a/Sema/Sema.h b/Sema/Sema.h
index e78bf30..3722ec2 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -250,6 +250,8 @@
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 12f7d7a..f5115db 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -1678,7 +1678,10 @@
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::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 @@
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;
+ }
+}