]> granicus.if.org Git - clang/commitdiff
Adding in the subject for the init_priority attribute.
authorAaron Ballman <aaron@aaronballman.com>
Wed, 27 Nov 2013 16:34:09 +0000 (16:34 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Wed, 27 Nov 2013 16:34:09 +0000 (16:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195850 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
lib/Sema/SemaDeclAttr.cpp
test/SemaCXX/init-priority-attr.cpp

index 69c1eae7763c64c74e22547d75c28f6b94d330dc..6802c86aae6dd024a9f6a7f2117c342dcf3ca400 100644 (file)
@@ -730,7 +730,7 @@ def WorkGroupSizeHint :  InheritableAttr {
 def InitPriority : InheritableAttr {
   let Spellings = [GNU<"init_priority">];
   let Args = [UnsignedArgument<"Priority">];
-//  let Subjects = [Var];
+  let Subjects = SubjectList<[Var], ErrorDiag>;
 }
 
 def Section : InheritableAttr {
index 046054df51783fd9e386bcb7b26f44aa9f1c3bd6..57b8eba6afa25a2f278fa8b839ba6a3f4c33e83b 100644 (file)
@@ -2700,12 +2700,12 @@ static void handleInitPriorityAttr(Sema &S, Decl *D,
     return;
   }
   
-  if (!isa<VarDecl>(D) || S.getCurFunctionOrMethodDecl()) {
+  if (S.getCurFunctionOrMethodDecl()) {
     S.Diag(Attr.getLoc(), diag::err_init_priority_object_attr);
     Attr.setInvalid();
     return;
   }
-  QualType T = dyn_cast<VarDecl>(D)->getType();
+  QualType T = cast<VarDecl>(D)->getType();
   if (S.Context.getAsArrayType(T))
     T = S.Context.getBaseElementType(T);
   if (!T->getAs<RecordType>()) {
index a91eb60ba96cf5f84ac8a1592dc3de32b463edde..a2e6df26ba1b7b5ac3436c70e680f685efc0e6da 100644 (file)
@@ -25,8 +25,7 @@ Two coo[2]  __attribute__((init_priority(3)));        // expected-error {{init_priority
 
 Two koo[4]  __attribute__((init_priority(1.13))); // expected-error {{'init_priority' attribute requires an integer constant}}
 
-
-Two func()  __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}}
+Two func()  __attribute__((init_priority(1001))); // expected-error {{'init_priority' attribute only applies to variables}}
 
 int i  __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}}