From: Jason Merrill <jason@redhat.com>
To: Dodji Seketeli <dodji@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Benjamin De Kosnik <bkoz@redhat.com>
Subject: Re: [C++ PATCH] PR c++/45114 - Support alias templates
Date: Sun, 06 Nov 2011 10:13:00 -0000 [thread overview]
Message-ID: <4EB61005.5020001@redhat.com> (raw)
In-Reply-To: <m3wrbem9a4.fsf@redhat.com>
On 11/05/2011 07:36 PM, Dodji Seketeli wrote:
> +#define TYPE_DECL_NAMES_ALIAS_TEMPLATE_P(NODE) \
This doesn't seem to be needed anymore.
> +dump_alias_template_specialization (tree t, int flags)
> +{
> + gcc_assert (alias_template_specialization_p (t));
> +
> + if (CLASS_TYPE_P (t))
> + dump_aggr_type (t, flags);
> + else
> + {
> + tree name;
> + name = TYPE_IDENTIFIER (t);
> + pp_cxx_tree_identifier (cxx_pp, name);
> + dump_template_parms (TYPE_TEMPLATE_INFO (t),
> + /*primary=*/false,
> + flags & ~TFF_TEMPLATE_HEADER);
> + }
Why do you treat class and non-class aliases differently? In both cases
I think we want alias specializations to be printed as
scope::name<args>. We don't want to print 'class' since such a
specialization cannot be used in an elaborated-type-specifier.
7.1.6.3/2: "If the identifier resolves to a typedef-name or
the simple-template-id resolves to an alias template specialization, the
elaborated-type-specifier is ill-formed."
> + if (alias_template_specialization_p (t))
> + {
> + dump_alias_template_specialization (t, flags);
> + return;
> + }
> + else if ((flags & TFF_CHASE_TYPEDEF)
> + || DECL_SELF_REFERENCE_P (decl)
> + || (!flag_pretty_templates
> + && DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl)))
> t = strip_typedefs (t);
The order of these two should be reversed. We want TFF_CHASE_TYPEDEF
and -fno-pretty-templates to strip alias-templates as well as
non-template typedefs.
> - /* If the next keyword is `namespace', we have a
> + /* If the next keyword is `namespace', we have either a
> namespace-alias-definition. */
This change seems unintended.
> + if (!(type_decl != NULL_TREE
> + && TREE_CODE (type_decl) == TYPE_DECL
> + && TYPE_DECL_ALIAS_P (type_decl)
> + && DECL_TEMPLATE_INSTANTIATION (type_decl)))
> + cp_parser_simulate_error (parser);
I think the TYPE_DECL_ALIAS_P and DECL_TEMPLATE_INSTANTIATION checks
should be an assert instead; at this point any TYPE_DECL we get should
satisfy those.
> - || (TYPE_P (t) && TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
> + || (TYPE_P (t)
> + && TYPE_NAME (t)
> + && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
> + && TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
In C++ I think a non-null TYPE_NAME is always a TYPE_DECL.
>> Why not set r here, as for the other cases?
> Because I'd like to handle alias declarations even for cases handled
> by the other cases where, r is end up being NULL.
Hmm. With this code we end up substituting into a non-template alias
declaration at file scope. I think if you check
alias_template_specialization_p before checking for class/function scope
that should handle the cases you need.
Jason
next prev parent reply other threads:[~2011-11-06 4:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-27 19:26 Dodji Seketeli
2011-10-27 22:16 ` Gabriel Dos Reis
2011-10-27 22:40 ` Jason Merrill
2011-11-06 2:19 ` Dodji Seketeli
2011-11-06 10:13 ` Jason Merrill [this message]
2011-11-07 15:57 ` Dodji Seketeli
2011-11-07 18:39 ` Jason Merrill
2011-11-08 3:40 ` [C++ PATCH] Fix context handling of alias declaration Dodji Seketeli
2011-11-08 5:13 ` Jason Merrill
2011-11-08 20:15 ` [C++ PATCH] PR c++/45114 - Support alias templates H.J. Lu
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=4EB61005.5020001@redhat.com \
--to=jason@redhat.com \
--cc=bkoz@redhat.com \
--cc=dodji@redhat.com \
--cc=gcc-patches@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).