PR c++/80598
* call.c (build_over_call): In templates set TREE_USED (first_fn) when
not calling mark_used for the benefit of -Wunused-function warning.
* g++.dg/warn/Wunused-function4.C: New test.
From-SVN: r258370
+2018-03-08 Jason Merrill <jason@redhat.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/80598
+ * call.c (build_over_call): In templates set TREE_USED (first_fn) when
+ not calling mark_used for the benefit of -Wunused-function warning.
+
2018-03-06 Jason Merrill <jason@redhat.com>
* lambda.c (is_capture_proxy_with_ref): Remove.
if (undeduced_auto_decl (fn))
mark_used (fn, complain);
+ else
+ /* Otherwise set TREE_USED for the benefit of -Wunused-function.
+ See PR80598. */
+ TREE_USED (fn) = 1;
return_type = TREE_TYPE (TREE_TYPE (fn));
nargs = vec_safe_length (args);
2018-03-08 Jakub Jelinek <jakub@redhat.com>
+ PR c++/80598
+ * g++.dg/warn/Wunused-function4.C: New test.
+
PR inline-asm/84742
* gcc.target/i386/pr84742-1.c: New test.
* gcc.target/i386/pr84742-2.c: New test.
--- /dev/null
+// PR c++/80598
+// { dg-do compile }
+// { dg-options "-Wunused-function" }
+
+static void
+foo () // { dg-bogus "defined but not used" }
+{
+}
+
+static void
+bar () // { dg-warning "defined but not used" }
+{
+}
+
+template <class T>
+int
+baz (T x)
+{
+ foo ();
+ return 0;
+}