From: Nathan Sidwell Date: Sat, 23 May 2015 22:28:54 +0000 (+0000) Subject: re PR c++/65936 (ICE: canonical types differ for identical types) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=84a3423b97784ba86bcb37efb39fd528de3671cb;p=gcc.git re PR c++/65936 (ICE: canonical types differ for identical types) cp/ PR c++/65936 * pt.c (lookup_template_class_1): Copy may_alias attribute too. testsuite/ PR c++/65936 * g++.dg/template/pr65936.C: New. From-SVN: r223613 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7c9b77e0ae9..35d5f34e63f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-05-23 Nathan Sidwell + + PR c++/65936 + * pt.c (lookup_template_class_1): Copy may_alias attribute too. + 2015-05-22 Jim Wilson * Make-lang.in (check_g++_parallelize): Update comment. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 407ef7d7d0a..a0c5d7cd586 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7905,15 +7905,22 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, 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)); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fe5d962c36c..e302f01257a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-05-23 Nathan Sidwell + + PR c++/65936 + * g++.dg/template/pr65936.C: New. + 2015-05-22 Marc Glisse PR tree-optimization/63387 diff --git a/gcc/testsuite/g++.dg/template/pr65936.C b/gcc/testsuite/g++.dg/template/pr65936.C new file mode 100644 index 00000000000..afa227686d1 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr65936.C @@ -0,0 +1,21 @@ +// checking ICE in canonical typing + +class A; + +template struct B +{ + typedef A type; +}; + +template class C + : public B::type +{ +} __attribute__ ((__may_alias__)); + +class A +{ + operator const C &() + { + return *static_cast *> (this); + } +};