public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-8256] c++: partial ordering with dependent NTTP type [PR105289]
@ 2022-04-26  1:49 Patrick Palka
  0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2022-04-26  1:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:288e4c64f6b4806358aabc9b99b2fba72bf04bf6

commit r12-8256-g288e4c64f6b4806358aabc9b99b2fba72bf04bf6
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon Apr 25 21:46:56 2022 -0400

    c++: partial ordering with dependent NTTP type [PR105289]
    
    Here ever since r11-6483-ge2e2f3f2c9400f we're rejecting and crashing
    on (respectively) two testcases that we used to accept in C++17 mode
    since r8-1437-g3da557ec145823.  Both testcases declare a partial
    specialization of a primary template that has an NTTP with dependent
    type, and the validity of these partial specializations is unclear and
    the subject of PR86193 / CWG 455.
    
    So for now, this minimal patch just aims to fix the crash in the second
    testcase.  During deduction, when checking whether the type of an NTTP
    uses still-undeduced parameters, we were incorrectly substituting into
    the previously substituted type instead of into its original type.
    
    In passing this patch also downgrades the "not more specialized"
    diagnostic from a permerror to a pedwarn.
    
            PR c++/105289
            PR c++/86193
    
    gcc/cp/ChangeLog:
    
            * pt.cc (process_partial_specialization): Downgrade "partial
            specialization isn't more specialized" diagnostic from permerror
            to an on-by-default pedwarn.
            (unify) <case TEMPLATE_PARM_INDEX>: When substituting into the
            NTTP type a second time, use the original type not the
            substituted type.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/template/partial-specialization11.C: New test.
            * g++.dg/template/partial-specialization12.C: New test.

Diff:
---
 gcc/cp/pt.cc                                             |  7 ++++---
 gcc/testsuite/g++.dg/template/partial-specialization11.C | 11 +++++++++++
 gcc/testsuite/g++.dg/template/partial-specialization12.C | 12 ++++++++++++
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index dde62ee052d..7dd9e6788f4 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -5227,8 +5227,9 @@ process_partial_specialization (tree decl)
 	   && !get_partial_spec_bindings (maintmpl, maintmpl, specargs))
     {
       auto_diagnostic_group d;
-      if (permerror (input_location, "partial specialization %qD is not "
-		     "more specialized than", decl))
+      if (pedwarn (input_location, 0,
+		   "partial specialization %qD is not more specialized than",
+		   decl))
 	inform (DECL_SOURCE_LOCATION (maintmpl), "primary template %qD",
 		maintmpl);
     }
@@ -24299,7 +24300,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
 	      /* Now check whether the type of this parameter is still
 		 dependent, and give up if so.  */
 	      ++processing_template_decl;
-	      tparm = tsubst (tparm, targs, tf_none, NULL_TREE);
+	      tparm = tsubst (TREE_TYPE (parm), targs, tf_none, NULL_TREE);
 	      --processing_template_decl;
 	      if (uses_template_parms (tparm))
 		return unify_success (explain_p);
diff --git a/gcc/testsuite/g++.dg/template/partial-specialization11.C b/gcc/testsuite/g++.dg/template/partial-specialization11.C
new file mode 100644
index 00000000000..556224a3104
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/partial-specialization11.C
@@ -0,0 +1,11 @@
+// PR c++/86193
+// CWG 455 (active)
+// { dg-options "" } // clear -pedantic-errors
+
+template<class T> struct value_type;
+
+template<class T, typename value_type<T>::type V>
+struct A;
+
+template<class T, int V>
+struct A<T*, V> { }; // { dg-warning "not more specialized" }
diff --git a/gcc/testsuite/g++.dg/template/partial-specialization12.C b/gcc/testsuite/g++.dg/template/partial-specialization12.C
new file mode 100644
index 00000000000..5f51e8a27de
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/partial-specialization12.C
@@ -0,0 +1,12 @@
+// PR c++/105289
+// CWG 455 (active)
+// { dg-do compile { target c++11 } }
+
+template<class T>
+struct value_type;
+
+template<class List, typename value_type<List>::type Element>
+struct push_front_vlist;
+
+template<template<class X, X...> class XList, class T, T Arg, T... Vs>
+struct push_front_vlist<XList<T, Vs...>, Arg> { }; // { dg-error "not more specialized" }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-26  1:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26  1:49 [gcc r12-8256] c++: partial ordering with dependent NTTP type [PR105289] Patrick Palka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).