diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2019-05-03 07:19:46 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2019-05-03 07:19:46 +0000 |
commit | 6ef4cf339ce48cf922534c163eaec4bcbf85604f (patch) | |
tree | b5d19c07393491d603709dc14756c3c2c89bcb90 | |
parent | a121961bcb19ce431c7e2be54afedf67c3407d8c (diff) |
[Sema][ObjC] Disable -Wunused-parameter for ObjC methods
The warning isn't very useful when the function is an ObjC method.
rdar://problem/41561853
Differential Revision: https://reviews.llvm.org/D61147
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359864 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | test/SemaObjC/method-unused-attribute.m | 8 | ||||
-rw-r--r-- | test/SemaObjC/unused.m | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index a97e3573b9..379e2aefb4 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -13353,8 +13353,6 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, assert(MD == getCurMethodDecl() && "Method parsing confused"); MD->setBody(Body); if (!MD->isInvalidDecl()) { - if (!MD->hasSkippedBody()) - DiagnoseUnusedParameters(MD->parameters()); DiagnoseSizeOfParametersAndReturnValue(MD->parameters(), MD->getReturnType(), MD); diff --git a/test/SemaObjC/method-unused-attribute.m b/test/SemaObjC/method-unused-attribute.m index d604c3975c..d8e9659b51 100644 --- a/test/SemaObjC/method-unused-attribute.m +++ b/test/SemaObjC/method-unused-attribute.m @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify -Wno-objc-root-class %s +// -Wunused-parameter ignores ObjC method parameters that are unused. + +// expected-no-diagnostics + @interface INTF - (void) correct_use_of_unused: (void *) notice : (id)another_arg; - (void) will_warn_unused_arg: (void *) notice : (id)warn_unused; @@ -9,7 +13,7 @@ @implementation INTF - (void) correct_use_of_unused: (void *) __attribute__((unused)) notice : (id) __attribute__((unused)) newarg{ } -- (void) will_warn_unused_arg: (void *) __attribute__((unused)) notice : (id)warn_unused {} // expected-warning {{unused parameter 'warn_unused'}} -- (void) unused_attr_on_decl_ignored: (void *) will_warn{} // expected-warning {{unused parameter 'will_warn'}} +- (void) will_warn_unused_arg: (void *) __attribute__((unused)) notice : (id)warn_unused {} +- (void) unused_attr_on_decl_ignored: (void *) will_warn{} @end diff --git a/test/SemaObjC/unused.m b/test/SemaObjC/unused.m index f31e4709f5..088f5b4577 100644 --- a/test/SemaObjC/unused.m +++ b/test/SemaObjC/unused.m @@ -33,7 +33,7 @@ void test2() { // expected-note {{introduce a parameter name to make 'x' part of the selector}} \ // expected-note {{or insert whitespace before ':' to use 'x' as parameter name and have an empty entry in the selector}} -(int)y: // expected-warning {{unused}} expected-warning {{'y' used as the name of the previous parameter rather than as part of the selector}} \ +(int)y: // expected-warning {{'y' used as the name of the previous parameter rather than as part of the selector}} \ // expected-note {{introduce a parameter name to make 'y' part of the selector}} \ // expected-note {{or insert whitespace before ':' to use 'y' as parameter name and have an empty entry in the selector}} (int) __attribute__((unused))z { return x; } |