2015-05-21 Nathan Sidwell <nathan@acm.org>
cp/
PR c++/65936
pt.c (lookup_template_class_1): Apply may_alias attribute here.
testsuite/
* g++.dg/template/pr65936.C: New.
===================================================================
@@ -7856,6 +7856,10 @@ lookup_template_class_1 (tree d1, tree a
= CLASSTYPE_DECLARED_CLASS (template_type);
SET_CLASSTYPE_IMPLICIT_INSTANTIATION (t);
TYPE_FOR_JAVA (t) = TYPE_FOR_JAVA (template_type);
+ if (lookup_attribute ("may_alias",
+ TYPE_ATTRIBUTES (template_type)))
+ TYPE_ATTRIBUTES (t) = tree_cons (get_identifier ("may_alias"),
+ NULL_TREE, NULL_TREE);
/* A local class. Make sure the decl gets registered properly. */
if (context == current_function_decl)
===================================================================
@@ -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);
+ }
+};