summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp4
-rw-r--r--clang/test/SemaCXX/cxx11-unused.cpp33
2 files changed, 36 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 42084210807..e9c3c39b132 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9921,7 +9921,9 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
Diag(FD->getLocation(), diag::warn_pure_function_definition);
if (!FD->isInvalidDecl()) {
- DiagnoseUnusedParameters(FD->param_begin(), FD->param_end());
+ // Don't diagnose unused parameters of defaulted or deleted functions.
+ if (Body)
+ DiagnoseUnusedParameters(FD->param_begin(), FD->param_end());
DiagnoseSizeOfParametersAndReturnValue(FD->param_begin(), FD->param_end(),
FD->getReturnType(), FD);
diff --git a/clang/test/SemaCXX/cxx11-unused.cpp b/clang/test/SemaCXX/cxx11-unused.cpp
new file mode 100644
index 00000000000..1e25bd51572
--- /dev/null
+++ b/clang/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 <typename T>
+ 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;
OpenPOWER on IntegriCloud