mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 12:26:52 +08:00
[Sema] Do not show unused parameter warnings when body is skipped
Summary: Without the function body, we cannot determine is parameter was used. Reviewers: ioeric, sammccall Reviewed By: sammccall Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53456 llvm-svn: 345122
This commit is contained in:
@@ -13037,7 +13037,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
|
||||
|
||||
if (!FD->isInvalidDecl()) {
|
||||
// Don't diagnose unused parameters of defaulted or deleted functions.
|
||||
if (!FD->isDeleted() && !FD->isDefaulted())
|
||||
if (!FD->isDeleted() && !FD->isDefaulted() && !FD->hasSkippedBody())
|
||||
DiagnoseUnusedParameters(FD->parameters());
|
||||
DiagnoseSizeOfParametersAndReturnValue(FD->parameters(),
|
||||
FD->getReturnType(), FD);
|
||||
@@ -13132,7 +13132,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
|
||||
assert(MD == getCurMethodDecl() && "Method parsing confused");
|
||||
MD->setBody(Body);
|
||||
if (!MD->isInvalidDecl()) {
|
||||
DiagnoseUnusedParameters(MD->parameters());
|
||||
if (!MD->hasSkippedBody())
|
||||
DiagnoseUnusedParameters(MD->parameters());
|
||||
DiagnoseSizeOfParametersAndReturnValue(MD->parameters(),
|
||||
MD->getReturnType(), MD);
|
||||
|
||||
|
||||
8
clang/test/Index/skipped-bodies-unused.cpp
Normal file
8
clang/test/Index/skipped-bodies-unused.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// RUN: env CINDEXTEST_SKIP_FUNCTION_BODIES=1 c-index-test -test-load-source all %s -Wunused-parameter 2>&1 \
|
||||
// RUN: | FileCheck %s
|
||||
|
||||
// No 'unused parameter' warnings should be shown when skipping the function bodies.
|
||||
inline int foo(int used, int unused) {
|
||||
used = 100;
|
||||
}
|
||||
// CHECK-NOT: warning: unused parameter
|
||||
Reference in New Issue
Block a user