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,
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...
}
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"));
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;
+ }
+}