re PR c++/65936 (ICE: canonical types differ for identical types)
authorNathan Sidwell <nathan@acm.org>
Sat, 23 May 2015 22:28:54 +0000 (22:28 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Sat, 23 May 2015 22:28:54 +0000 (22:28 +0000)
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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/pr65936.C [new file with mode: 0644]

index 7c9b77e0ae9d0631003f5b055825b23524c74f41..35d5f34e63f7c63232b650bdd7e4711c056846a1 100644 (file)
@@ -1,3 +1,8 @@
+2015-05-23  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/65936
+       * pt.c (lookup_template_class_1): Copy may_alias attribute too.
+
 2015-05-22  Jim Wilson  <jim.wilson@linaro.org>
 
        * Make-lang.in (check_g++_parallelize): Update comment.
index 407ef7d7d0a63a465b9cc41677d5983fe439e535..a0c5d7cd586b39204e3637fec1ca605da2685f91 100644 (file)
@@ -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));
            }
        }
 
index fe5d962c36c16a3e42c0cd7bdbeef4d6b3737cf3..e302f01257a2040b31519910e5a452097492e6af 100644 (file)
@@ -1,3 +1,8 @@
+2015-05-23  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/65936
+       * g++.dg/template/pr65936.C: New.
+
 2015-05-22  Marc Glisse  <marc.glisse@inria.fr>
 
        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 (file)
index 0000000..afa2276
--- /dev/null
@@ -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);
+  }
+};