Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -10797,8 +10797,13 @@ if (!FD->isInvalidDecl()) { // Don't diagnose unused parameters of defaulted or deleted functions. - if (!FD->isDeleted() && !FD->isDefaulted()) - DiagnoseUnusedParameters(FD->param_begin(), FD->param_end()); + if (!FD->isDeleted() && !FD->isDefaulted()) { + // Don't diagnose unused parameters in virtual methods or + // in methods that override base class methods. + const auto MD = dyn_cast(FD); + if (!MD || (MD->size_overridden_methods() == 0U && !MD->isVirtual())) + DiagnoseUnusedParameters(FD->param_begin(), FD->param_end()); + } DiagnoseSizeOfParametersAndReturnValue(FD->param_begin(), FD->param_end(), FD->getReturnType(), FD); Index: test/SemaCXX/warn-unused-parameters.cpp =================================================================== --- test/SemaCXX/warn-unused-parameters.cpp +++ test/SemaCXX/warn-unused-parameters.cpp @@ -32,3 +32,20 @@ auto l = [&t...]() { return sizeof...(s); }; return l(); } + +// Don't diagnose virtual methods or methods that override base class +// methods. +class Base { +public: + virtual void f(int x); +}; + +class Derived : public Base { +public: + // Don't warn in overridden methods. + virtual void f(int x) {} + + // Don't warn in virtual methods. + virtual void a(int x) {} +}; +