diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 69c1eae7763c..6802c86aae6d 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -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 { diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 046054df5178..57b8eba6afa2 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2700,12 +2700,12 @@ static void handleInitPriorityAttr(Sema &S, Decl *D, return; } - if (!isa(D) || S.getCurFunctionOrMethodDecl()) { + if (S.getCurFunctionOrMethodDecl()) { S.Diag(Attr.getLoc(), diag::err_init_priority_object_attr); Attr.setInvalid(); return; } - QualType T = dyn_cast(D)->getType(); + QualType T = cast(D)->getType(); if (S.Context.getAsArrayType(T)) T = S.Context.getBaseElementType(T); if (!T->getAs()) { diff --git a/clang/test/SemaCXX/init-priority-attr.cpp b/clang/test/SemaCXX/init-priority-attr.cpp index a91eb60ba96c..a2e6df26ba1b 100644 --- a/clang/test/SemaCXX/init-priority-attr.cpp +++ b/clang/test/SemaCXX/init-priority-attr.cpp @@ -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}}