From: Adam Butcher <adam@jessamine.co.uk>
To: Jason Merrill <jason@redhat.com>
Cc: <gcc-patches@gcc.gnu.org>, Volker Reichelt <reichelt@gcc.gnu.org>
Subject: Re: [C++ PATCH] Refactor implicit function template implementation and fix 58534, 58536, 58548, 58549 and 58637.
Date: Mon, 11 Nov 2013 21:45:00 -0000 [thread overview]
Message-ID: <cf00d97be2abc78828bccb4a3c6294cd@imap.force9.net> (raw)
In-Reply-To: <52801507.80900@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2421 bytes --]
On 2013-11-10 23:21, Jason Merrill wrote:
> On 11/10/2013 02:39 PM, Adam Butcher wrote:
>> I assumed that tsubst simply doesn't do anything with a
>> null tree substitution (i.e. it is an identity op).
>
> Substituting NULL_TREE for a template parameter gives a template
> parameter with a reduced level; this happens during partial
> instantiation.
>
Ah, OK.
>> Since we are tsubsting the declaration here and we only want to
>> adjust
>> the template parameter types themselves at their declaration is this
>> really necessary? I've no problem with implementing this if it
>> truly is
>> necessary but I don't want to add unnecessary cycles if not.
>
> The difference between setting copying a pointer to a vec versus
> setting it to null seems completely negligible to me.
>
Sure. I was more concerned with allocating vecs for each outer list
and copying the parms over versus allocating a 'null' placeholder list
for each level which we're not concerned about. No worries though, I've
proceeded with your suggestion below.
> I think it is necessary in case the function parameter type involves
> template parameters from the enclosing context as well as implicit
> template parameters.
>
>> One other thing, by 'copy' I take it you mean copy the tree vecs of
>> the
>> enclosing levels only, not also the types within them.
>
> Yes, using add_outermost_template_args.
>
I have done this (diff -w -b follows). The route to this seems even
more costly though; current_template_parms needs to first be converted
to a vec by current_template_args() then the last nesting level is
thrown away and replaced with the one we're working on. It's all
working but I'm wondering whether a custom loop here would be better.
>> And I also assume that I'll need to set the currently unset types in
>> the inner
>> level also?
>
> Can you have explicit template parameters at the same level as the
> implicit ones?
>
Yes.
> If so, then their places in the vec will need to be
> set appropriately in case they are used in the function parameter
> type.
>
OK. I had testcases that appeared to pass OK with the previous
NULL_TREE tsubst but maybe I wasn't checking something (perhaps a
combination of an explicit template parm type and an auto in a single
parm).
End result is that everything looks OK though so we might be able to
get the C++14 lambda support marked as "in 4.9" soon hopefully.
Cheers,
Adam
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mods3.diff --]
[-- Type: text/x-c; name=mods3.diff, Size: 1473 bytes --]
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 360d8a3..69c7688 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -21641,6 +21641,10 @@ convert_generic_types_to_packs (tree parm, int start_idx, int end_idx)
current = INNERMOST_TEMPLATE_PARMS (current);
tree replacement = make_tree_vec (TREE_VEC_LENGTH (current));
+ for (int i = 0; i < start_idx; ++i)
+ TREE_VEC_ELT (replacement, i)
+ = TREE_TYPE (TREE_VALUE (TREE_VEC_ELT (current, i)));
+
for (int i = start_idx; i < end_idx; ++i)
{
/* Create a distinct parameter pack type from the current parm and add it
@@ -21662,18 +21666,15 @@ convert_generic_types_to_packs (tree parm, int start_idx, int end_idx)
TREE_VALUE (TREE_VEC_ELT (current, i)) = TREE_CHAIN (t);
}
+ for (int i = end_idx, e = TREE_VEC_LENGTH (current); i < e; ++i)
+ TREE_VEC_ELT (replacement, i)
+ = TREE_TYPE (TREE_VALUE (TREE_VEC_ELT (current, i)));
+
if (depth > 1)
- {
/* Build up a tree vec of empty tree vecs up to the inner substitution
args built above. */
-
- tree inner = replacement;
- replacement = make_tree_vec (depth);
- int last = depth - 1;
- for (int i = 0; i < last; ++i)
- TREE_VEC_ELT (replacement, i) = make_tree_vec (0);
- TREE_VEC_ELT (replacement, last) = inner;
- }
+ replacement = add_outermost_template_args (current_template_args (),
+ replacement);
return tsubst (parm, replacement, tf_none, NULL_TREE);
}
next prev parent reply other threads:[~2013-11-11 19:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-02 10:03 [SKETCH] " Adam Butcher
2013-11-02 10:03 ` [C++ PATCH 2/3] Support implicit parameter packs Adam Butcher
2013-11-02 10:03 ` [C++ PATCH 3/3] Add some generic lambda test cases Adam Butcher
2013-11-02 10:03 ` [C++ PATCH 1/3] Refactor implicit function template implementation and fix 58534, 58536, 58548, 58549 and 58637 Adam Butcher
2013-11-08 19:10 ` [C++ PATCH] " Jason Merrill
2013-11-09 13:56 ` Adam Butcher
2013-11-09 20:16 ` Adam Butcher
2013-11-10 10:34 ` Jason Merrill
2013-11-10 12:08 ` Adam Butcher
2013-11-10 16:14 ` Adam Butcher
2013-11-10 19:54 ` Jason Merrill
2013-11-10 20:28 ` Adam Butcher
2013-11-11 2:41 ` Jason Merrill
2013-11-11 21:45 ` Adam Butcher [this message]
2013-11-12 7:25 ` 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=cf00d97be2abc78828bccb4a3c6294cd@imap.force9.net \
--to=adam@jessamine.co.uk \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=reichelt@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).