aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/pt.cc2
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/nodiscard1.C13
-rw-r--r--gcc/testsuite/g++.dg/warn/Wctad-maybe-unsupported4.C13
3 files changed, 27 insertions, 1 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index eeebc4c..63794a4 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -30091,7 +30091,7 @@ do_class_deduction (tree ptype, tree tmpl, tree init,
/* If CTAD succeeded but the type doesn't have any explicit deduction
guides, this deduction might not be what the user intended. */
- if (fndecl != error_mark_node && !any_dguides_p)
+ if (fndecl != error_mark_node && !any_dguides_p && (complain & tf_warning))
{
if ((!DECL_IN_SYSTEM_HEADER (fndecl)
|| global_dc->dc_warn_system_headers)
diff --git a/gcc/testsuite/g++.dg/cpp2a/nodiscard1.C b/gcc/testsuite/g++.dg/cpp2a/nodiscard1.C
new file mode 100644
index 0000000..c3c5094
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/nodiscard1.C
@@ -0,0 +1,13 @@
+// PR c++/105143
+// { dg-do compile { target c++20 } }
+// We used to crash here with "Error reporting routines re-entered".
+
+template<class...> struct A { };
+
+template<A V> using type = int;
+
+template<A V> [[nodiscard]] type<V> get();
+
+int main() {
+ get<{}>(); // { dg-warning "nodiscard" }
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wctad-maybe-unsupported4.C b/gcc/testsuite/g++.dg/warn/Wctad-maybe-unsupported4.C
new file mode 100644
index 0000000..92ed821
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wctad-maybe-unsupported4.C
@@ -0,0 +1,13 @@
+// PR c++/105143
+// { dg-do compile { target c++17 } }
+// { dg-additional-options "-Werror=ctad-maybe-unsupported" }
+
+template<class...> struct A { };
+
+template<template<class...> class TT> auto f(...) -> decltype(TT()); // #1
+template<template<class...> class TT> void f(int); // #2
+
+int main() {
+ f<A>(0); // Calls #2 without issuing a -Wctad-maybe-unsupported
+ // diagnostic for #1.
+}