From 34ee86d7498e952e07de38cec6e79cb036386eb1 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Sat, 23 Nov 2013 22:29:11 +0000 Subject: [PATCH] Remove optional parameter bit from attribute ObjCSuppressProtocol. This refines some diagnostics and reduces some boilerplate checking logic. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195560 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/Attr.td | 2 +- lib/Sema/SemaDeclAttr.cpp | 3 +-- test/SemaObjC/protocols-suppress-conformance.m | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 5902932be2..ff1d495d67 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -645,7 +645,7 @@ def ObjCRootClass : InheritableAttr { def ObjCSuppressProtocol : InheritableAttr { let Spellings = [GNU<"objc_suppress_protocol_methods">]; let Subjects = [ObjCInterface]; - let Args = [IdentifierArgument<"Protocol", 1>]; + let Args = [IdentifierArgument<"Protocol">]; } def Overloadable : Attr { diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 7ae873d7f9..5a0b72fcb5 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -2142,8 +2142,7 @@ static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D, return; } - IdentifierLoc *Parm = (Attr.getNumArgs() == 1 && Attr.isArgIdent(0)) - ? Attr.getArgAsIdent(0) : 0; + IdentifierLoc *Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0; if (!Parm) { S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 1; diff --git a/test/SemaObjC/protocols-suppress-conformance.m b/test/SemaObjC/protocols-suppress-conformance.m index 61c950a7b0..880819e407 100644 --- a/test/SemaObjC/protocols-suppress-conformance.m +++ b/test/SemaObjC/protocols-suppress-conformance.m @@ -68,8 +68,8 @@ __attribute__((objc_supress_protocol(Protocol))) @interface ClassE (MyCat) @end // expected-error {{attributes may not be specified on a category}} // The attribute requires one or more identifiers. -__attribute__((objc_suppress_protocol_methods())) -@interface ClassF @end // expected-error {{parameter of 'objc_suppress_protocol_methods' attribute must be a single name of an Objective-C protocol}} +__attribute__((objc_suppress_protocol_methods())) // expected-error {{'objc_suppress_protocol_methods' attribute takes one argument}} +@interface ClassF @end // The attribute requires one or more identifiers. __attribute__((objc_suppress_protocol_methods(ProtoA, ProtoB))) // expected-error {{use of undeclared identifier 'ProtoB'}} -- 2.40.0