+2019-11-13 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89070 - bogus [[nodiscard]] warning in SFINAE.
+ * cvt.c (convert_to_void): Guard maybe_warn_nodiscard calls with
+ tf_warning.
+
2019-11-13 Richard Sandiford <richard.sandiford@arm.com>
PR c++/92206
if (DECL_DESTRUCTOR_P (fn))
return expr;
- maybe_warn_nodiscard (expr, implicit);
+ if (complain & tf_warning)
+ maybe_warn_nodiscard (expr, implicit);
break;
case INDIRECT_REF:
&& !is_reference)
warning_at (loc, OPT_Wunused_value, "value computed is not used");
expr = TREE_OPERAND (expr, 0);
- if (TREE_CODE (expr) == CALL_EXPR)
+ if (TREE_CODE (expr) == CALL_EXPR
+ && (complain & tf_warning))
maybe_warn_nodiscard (expr, implicit);
}
AGGR_INIT_EXPR_ARGP (init));
}
}
- maybe_warn_nodiscard (expr, implicit);
+ if (complain & tf_warning)
+ maybe_warn_nodiscard (expr, implicit);
break;
default:;
+2019-11-13 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89070 - bogus [[nodiscard]] warning in SFINAE.
+ * g++.dg/cpp1z/nodiscard7.C: New test.
+
2019-11-13 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/c11-float-3.c, gcc.dg/c2x-float-1.c: New tests.
--- /dev/null
+// PR c++/89070 - bogus [[nodiscard]] warning in SFINAE.
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+ [[nodiscard]] static int match() { return 42; }
+};
+
+template<typename T>
+auto g() -> decltype( T::match(), bool() )
+{
+ return T::match();
+}
+
+int main()
+{
+ g<A>();
+}