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