]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: injected class name as default ttp arg [PR58538]
authorJason Merrill <jason@redhat.com>
Wed, 15 Mar 2023 03:16:21 +0000 (23:16 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 15 Mar 2023 12:44:43 +0000 (08:44 -0400)
This function needs to handle this case like convert_template_argument.

PR c++/58538

gcc/cp/ChangeLog:

* semantics.cc (check_template_template_default_arg): Check
maybe_get_template_decl_from_type_decl.

gcc/testsuite/ChangeLog:

* g++.dg/template/ttp7.C: Remove expected error.

gcc/cp/semantics.cc
gcc/testsuite/g++.dg/template/ttp7.C

index d67a9b26719f28c625b28e0663b8de5d05b76a87..57dd7b66da83c4792a58997a6a1ffd10976adb3a 100644 (file)
@@ -3468,8 +3468,13 @@ check_template_template_default_arg (tree argument)
       && TREE_CODE (argument) != UNBOUND_CLASS_TEMPLATE)
     {
       if (TREE_CODE (argument) == TYPE_DECL)
-       error ("invalid use of type %qT as a default value for a template "
-              "template-parameter", TREE_TYPE (argument));
+       {
+         if (tree t = maybe_get_template_decl_from_type_decl (argument))
+           if (TREE_CODE (t) == TEMPLATE_DECL)
+             return t;
+         error ("invalid use of type %qT as a default value for a template "
+                "template-parameter", TREE_TYPE (argument));
+       }
       else
        error ("invalid default argument for a template template parameter");
       return error_mark_node;
index 0bcaa8f729229c0e10b5f4c2ea00b8702d6e9673..672077e7e7d265f63cac1a452d7fb549d85781f0 100644 (file)
@@ -11,6 +11,6 @@ template<template<int> class = A<0> > struct B2 {};  // { dg-error "as a default
 
 template <typename T>
 struct S {
-  template <template <typename> class = S>   struct I1 {};  // { dg-error "as a default value" }
+  template <template <typename> class = S>   struct I1 {}; // PR c++/58538
   template <template <typename> class = ::S> struct I2 {};
 };