From: Paolo Carlini <paolo.carlini@oracle.com>
To: Jason Merrill <jason@redhat.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ Patch] PR 53856
Date: Mon, 05 Oct 2015 17:45:00 -0000 [thread overview]
Message-ID: <5612B723.8060302@oracle.com> (raw)
In-Reply-To: <5612AEFF.3090406@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 524 bytes --]
Hi,
On 10/05/2015 07:10 PM, Jason Merrill wrote:
> On 10/05/2015 12:50 PM, Paolo Carlini wrote:
>> + else if (!current_class_type || CLASSTYPE_IS_TEMPLATE
>> (current_class_type))
>> + msg = G_("default argument for template parameter for class
>> enclosing %qD");
>
> Why would this be right when !current_class_type?
Yes, it doesn't make much sense, but at least it's conservatively
correct ;) I'm finishing regtesting the below, everything seems fine so
far. Ok if it passes?
Thanks,
Paolo.
//////////////////
[-- Attachment #2: patch_53856_2b --]
[-- Type: text/plain, Size: 1908 bytes --]
Index: cp/pt.c
===================================================================
--- cp/pt.c (revision 228467)
+++ cp/pt.c (working copy)
@@ -4940,8 +4940,15 @@ check_default_tmpl_args (tree decl, tree parms, bo
else if (is_partial)
msg = G_("default template arguments may not be used in "
"partial specializations");
+ else if (current_class_type && CLASSTYPE_IS_TEMPLATE (current_class_type))
+ msg = G_("default argument for template parameter for class enclosing %qD");
else
- msg = G_("default argument for template parameter for class enclosing %qD");
+ /* Per [temp.param]/9, "A default template-argument shall not be
+ specified in the template-parameter-lists of the definition of
+ a member of a class template that appears outside of the member's
+ class.", thus if we aren't handling a member of a class template
+ there is no need to examine the parameters. */
+ return true;
if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
/* If we're inside a class definition, there's no need to
Index: testsuite/g++.dg/template/defarg19.C
===================================================================
--- testsuite/g++.dg/template/defarg19.C (revision 0)
+++ testsuite/g++.dg/template/defarg19.C (working copy)
@@ -0,0 +1,15 @@
+// PR c++/53856
+
+template<typename T>
+struct A
+{
+ struct B;
+};
+
+template<typename T = int>
+struct A<T>::B // { dg-error "default argument" }
+{
+ int i;
+};
+
+A<int>::B b = { };
Index: testsuite/g++.dg/template/defarg20.C
===================================================================
--- testsuite/g++.dg/template/defarg20.C (revision 0)
+++ testsuite/g++.dg/template/defarg20.C (working copy)
@@ -0,0 +1,15 @@
+// PR c++/53856
+
+struct A
+{
+ template<typename T>
+ struct B;
+};
+
+template<typename T = int>
+struct A::B
+{
+ int i;
+};
+
+A::B<int> b = { };
next prev parent reply other threads:[~2015-10-05 17:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 19:41 Paolo Carlini
2015-09-24 13:33 ` Jason Merrill
2015-10-05 16:50 ` Paolo Carlini
2015-10-05 17:10 ` Jason Merrill
2015-10-05 17:45 ` Paolo Carlini [this message]
2015-10-05 17:46 ` Jason Merrill
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=5612B723.8060302@oracle.com \
--to=paolo.carlini@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/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).