+2019-12-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/59655
+ * pt.c (push_tinst_level_loc): If limit_bad_template_recursion,
+ set TREE_NO_WARNING on tldcl.
+ * decl2.c (no_linkage_error): Treat templates with TREE_NO_WARNING
+ as defined during error recovery.
+
2019-12-13 Jason Merrill <jason@redhat.com>
PR c++/91165 - verify_gimple ICE with cached constexpr.
void
no_linkage_error (tree decl)
{
- if (cxx_dialect >= cxx11 && decl_defined_p (decl))
+ if (cxx_dialect >= cxx11
+ && (decl_defined_p (decl)
+ /* Treat templates which limit_bad_template_recursion decided
+ not to instantiate as if they were defined. */
+ || (errorcount + sorrycount > 0
+ && DECL_LANG_SPECIFIC (decl)
+ && DECL_TEMPLATE_INFO (decl)
+ && TREE_NO_WARNING (decl))))
/* In C++11 it's ok if the decl is defined. */
return;
tree t = no_linkage_check (TREE_TYPE (decl), /*relaxed_p=*/false);
anything else. Do allow deduction substitution and decls usable in
constant expressions. */
if (!targs && limit_bad_template_recursion (tldcl))
- return false;
+ {
+ /* Avoid no_linkage_errors and unused function warnings for this
+ decl. */
+ TREE_NO_WARNING (tldcl) = 1;
+ return false;
+ }
/* When not -quiet, dump template instantiations other than functions, since
announce_function will take care of those. */
2019-12-17 Jakub Jelinek <jakub@redhat.com>
+ PR c++/59655
+ * g++.dg/cpp0x/diag3.C: New test.
+
PR target/92841
* gcc.target/i386/pr92841.c: New test.
--- /dev/null
+// PR c++/59655
+// { dg-do compile { target c++11 } }
+
+template<typename T> struct A { static constexpr bool value = false; };
+
+struct B {
+ template<typename T>
+ B (T t)
+ {
+ static_assert (A<T>::value, "baz"); // { dg-error "static assertion failed" }
+ foo (t);
+ }
+ template<typename T> void foo (T) {} // { dg-bogus "used but never defined" }
+};
+
+int
+main ()
+{
+ B t([](int) { });
+}