On 05/21/15 21:47, Jason Merrill wrote:
How about adding may_alias support to the code a bit lower down that copies the abi_tag attribute?
Good idea. This keeps the non-copy behavior when the attribute is the last on the source attribute list, and fixes up the case for when there are both may_alias and abi_tag.
booted and tested on x86_64-linux ok? nathan
2015-05-22 Nathan Sidwell <nat...@acm.org> PR c++/65936 * pt.c (lookup_template_class_1): Copy may_alias attribute too. PR c++/65936 * g++.dg/template/pr65936.C: New. Index: cp/pt.c =================================================================== --- cp/pt.c (revision 223503) +++ cp/pt.c (working copy) @@ -7905,15 +7905,22 @@ lookup_template_class_1 (tree d1, tree a if (OVERLOAD_TYPE_P (t) && !DECL_ALIAS_TEMPLATE_P (gen_tmpl)) { - if (tree attributes - = lookup_attribute ("abi_tag", TYPE_ATTRIBUTES (template_type))) + static const char *tags[] = {"abi_tag", "may_alias"}; + + for (unsigned ix = 0; ix != 2; ix++) { - if (!TREE_CHAIN (attributes)) + tree attributes + = lookup_attribute (tags[ix], TYPE_ATTRIBUTES (template_type)); + + if (!attributes) + ; + else if (!TREE_CHAIN (attributes) && !TYPE_ATTRIBUTES (t)) TYPE_ATTRIBUTES (t) = attributes; else TYPE_ATTRIBUTES (t) - = build_tree_list (TREE_PURPOSE (attributes), - TREE_VALUE (attributes)); + = tree_cons (TREE_PURPOSE (attributes), + TREE_VALUE (attributes), + TYPE_ATTRIBUTES (t)); } } Index: testsuite/g++.dg/template/pr65936.C =================================================================== --- testsuite/g++.dg/template/pr65936.C (revision 0) +++ testsuite/g++.dg/template/pr65936.C (working copy) @@ -0,0 +1,21 @@ +// checking ICE in canonical typing + +class A; + +template <typename> struct B +{ + typedef A type; +}; + +template <class T> class C + : public B<T>::type +{ +} __attribute__ ((__may_alias__)); + +class A +{ + operator const C<int> &() + { + return *static_cast<const C<int> *> (this); + } +};