public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-6694] c++: injected class name as default ttp arg [PR58538]
Date: Wed, 15 Mar 2023 12:45:20 +0000 (GMT) [thread overview]
Message-ID: <20230315124520.987C53858421@sourceware.org> (raw)
https://gcc.gnu.org/g:40c1352c5a4530350012d6a922435cf491663daa
commit r13-6694-g40c1352c5a4530350012d6a922435cf491663daa
Author: Jason Merrill <jason@redhat.com>
Date: Tue Mar 14 23:16:21 2023 -0400
c++: injected class name as default ttp arg [PR58538]
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.
Diff:
---
gcc/cp/semantics.cc | 9 +++++++--
gcc/testsuite/g++.dg/template/ttp7.C | 2 +-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index d67a9b26719..57dd7b66da8 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -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;
diff --git a/gcc/testsuite/g++.dg/template/ttp7.C b/gcc/testsuite/g++.dg/template/ttp7.C
index 0bcaa8f7292..672077e7e7d 100644
--- a/gcc/testsuite/g++.dg/template/ttp7.C
+++ b/gcc/testsuite/g++.dg/template/ttp7.C
@@ -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 {};
};
reply other threads:[~2023-03-15 12:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230315124520.987C53858421@sourceware.org \
--to=jason@gcc.gnu.org \
--cc=gcc-cvs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).