]> granicus.if.org Git - clang/commitdiff
Fix an embarassing typo and add some very limited support for the aligned attribute.
authorAnders Carlsson <andersca@mac.com>
Wed, 19 Dec 2007 07:19:40 +0000 (07:19 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 19 Dec 2007 07:19:40 +0000 (07:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45195 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/Sema.h
Sema/SemaDecl.cpp

index e78bf308f70541fa4c07edc21c91a258e7d23284..3722ec25600a8a9688144a11faa8f2b7d062613c 100644 (file)
@@ -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,
index 12f7d7a3886ca1d140b30a611f712d80dfe18e9b..f5115dbaab29dd275c1392e0fa7032c1a40d2541 100644 (file)
@@ -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;
+  }    
+}