aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2016-04-05 23:47:21 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2016-04-05 23:47:21 +0000
commitc08d28acf853c3af2651c989acd034d5d6d3f8a4 (patch)
treecbfb0efa43d05266ba5f2e0ab232be4ab053fb2e /gcc
parentd5a28db09e14fff64b900ff0d31eabda96c008b3 (diff)
downloadgcc-c08d28acf853c3af2651c989acd034d5d6d3f8a4.zip
gcc-c08d28acf853c3af2651c989acd034d5d6d3f8a4.tar.gz
gcc-c08d28acf853c3af2651c989acd034d5d6d3f8a4.tar.bz2
re PR c++/70512 (ICE on valid code on x86_64-linux-gnu: canonical types differ for identical types)
PR c++/70512 * class.c (fixup_may_alias): New. (fixup_attribute_variants): Call it. * g++.dg/ext/attribute-may-alias-5.C: New. From-SVN: r234768
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/class.c21
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/ext/attribute-may-alias-5.C9
4 files changed, 41 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 77c0b5b20..3831b92 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 98cbab5..ade2001 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1978,6 +1978,21 @@ fixup_type_variants (tree t)
}
}
+/* 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. */
@@ -1993,6 +2008,10 @@ fixup_attribute_variants (tree t)
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;
@@ -2007,6 +2026,8 @@ fixup_attribute_variants (tree t)
else
TYPE_USER_ALIGN (variants) = user_align;
TYPE_ALIGN (variants) = valign;
+ if (may_alias)
+ fixup_may_alias (variants);
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e0ef05b..2e5954c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-05 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/70512
+ * g++.dg/ext/attribute-may-alias-5.C: New.
+
2016-04-05 Jakub Jelinek <jakub@redhat.com>
PR c++/70336
diff --git a/gcc/testsuite/g++.dg/ext/attribute-may-alias-5.C b/gcc/testsuite/g++.dg/ext/attribute-may-alias-5.C
new file mode 100644
index 0000000..198e2ba
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/attribute-may-alias-5.C
@@ -0,0 +1,9 @@
+// PR c++/70512
+
+struct S
+{
+ S& operator= (int)
+ {
+ return *this;
+ }
+} __attribute__ ((__may_alias__));