+2016-04-05 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/70512
+ * class.c (fixup_may_alias): New.
+ (fixup_attribute_variants): Call it.
+
2016-04-05 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/70452
}
}
+/* KLASS is a class that we're applying may_alias to after the body is
+ parsed. Fixup any POINTER_TO and REFERENCE_TO types. The
+ canonical type(s) will be implicitly updated. */
+
+static void
+fixup_may_alias (tree klass)
+{
+ tree t;
+
+ for (t = TYPE_POINTER_TO (klass); t; t = TYPE_NEXT_PTR_TO (t))
+ TYPE_REF_CAN_ALIAS_ALL (t) = true;
+ for (t = TYPE_REFERENCE_TO (klass); t; t = TYPE_NEXT_REF_TO (t))
+ TYPE_REF_CAN_ALIAS_ALL (t) = true;
+}
+
/* Early variant fixups: we apply attributes at the beginning of the class
definition, and we need to fix up any variants that have already been
made via elaborated-type-specifier so that check_qualified_type works. */
tree attrs = TYPE_ATTRIBUTES (t);
unsigned align = TYPE_ALIGN (t);
bool user_align = TYPE_USER_ALIGN (t);
+ bool may_alias = lookup_attribute ("may_alias", attrs);
+
+ if (may_alias)
+ fixup_may_alias (t);
for (variants = TYPE_NEXT_VARIANT (t);
variants;
else
TYPE_USER_ALIGN (variants) = user_align;
TYPE_ALIGN (variants) = valign;
+ if (may_alias)
+ fixup_may_alias (variants);
}
}
\f