summaryrefslogtreecommitdiffstats
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
commit721f601507a25016098131ce2c2ff8b0b09685f7 (patch)
tree6a1c66930cc5da94651ee4f835f8a8fb49d1cdc7
parente592175f80614f66074329351d5863b5653ac116 (diff)
downloadbcm5719-llvm-721f601507a25016098131ce2c2ff8b0b09685f7.tar.gz
bcm5719-llvm-721f601507a25016098131ce2c2ff8b0b09685f7.zip
Fix an embarassing typo and add some very limited support for the aligned attribute.
llvm-svn: 45195
-rw-r--r--clang/Sema/Sema.h2
-rw-r--r--clang/Sema/SemaDecl.cpp22
2 files changed, 23 insertions, 1 deletions
diff --git a/clang/Sema/Sema.h b/clang/Sema/Sema.h
index e78bf308f70..3722ec25600 100644
--- a/clang/Sema/Sema.h
+++ b/clang/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/clang/Sema/SemaDecl.cpp b/clang/Sema/SemaDecl.cpp
index 12f7d7a3886..f5115dbaab2 100644
--- a/clang/Sema/SemaDecl.cpp
+++ b/clang/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;
+ }
+}
OpenPOWER on IntegriCloud