Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -9932,9 +9932,13 @@ Diag(FD->getLocation(), diag::warn_pure_function_definition); if (!FD->isInvalidDecl()) { - DiagnoseUnusedParameters(FD->param_begin(), FD->param_end()); - DiagnoseSizeOfParametersAndReturnValue(FD->param_begin(), FD->param_end(), - FD->getReturnType(), FD); + // In case of cxx11, Body is null if function is marked deleted/ defaulted + // out-of-line. Calling these DiagnoseXXX in such cases is not useful. + if (Body) { + DiagnoseUnusedParameters(FD->param_begin(), FD->param_end()); + DiagnoseSizeOfParametersAndReturnValue( + FD->param_begin(), FD->param_end(), FD->getReturnType(), FD); + } // If this is a constructor, we need a vtable. if (CXXConstructorDecl *Constructor = dyn_cast(FD)) Index: test/SemaCXX/cxx11-unused.cpp =================================================================== --- /dev/null +++ test/SemaCXX/cxx11-unused.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -std=c++11 -verify %s -Wunused-parameter + +// PR19303 : Make sure we don't get a unused expression warning for deleted and +// defaulted functions + +// expected-no-diagnostics + +class A { +public: + int x; + A() = default; + ~A() = default; + A(const A &other) = delete; + + template + void SetX(T x) { + this->x = x; + }; + + void SetX1(int x); +}; + +template <> +void A::SetX(A x) = delete; + +class B { +public: + B() = default; + ~B() = default; + B(const B &other); +}; + +B::B(const B &other) = default;