From b6cb06b486508141178bcbbf788e610c05f97295 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 27 May 2015 20:36:14 +0000 Subject: [PATCH] re PR c++/66270 (ICE: canonical types differ for identical types) PR c++/66270 * tree.c (build_pointer_type_for_mode): Canonical type does not inherit can_alias_all. (build_reference_type_for_mode): Likewise. PR c++/66270 * g++.dg/ext/alias-canon3.C: New. From-SVN: r223773 --- gcc/cp/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/alias-canon3.C | 12 ++++++++++++ gcc/tree.c | 6 ++++-- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/alias-canon3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 92c47388f74..d30eeb775de 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2015-05-27 Nathan Sidwell + + PR c++/66270 + * tree.c (build_pointer_type_for_mode): Canonical type does not + inherit can_alias_all. + (build_reference_type_for_mode): Likewise. + 2015-05-24 Nathan Sidwell PR c++/66243 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9afe4489621..1923a2f2fba 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-05-27 Nathan Sidwell + + PR c++/66270 + * g++.dg/ext/alias-canon3.C: New. + 2015-05-27 Richard Biener PR tree-optimization/66272 diff --git a/gcc/testsuite/g++.dg/ext/alias-canon3.C b/gcc/testsuite/g++.dg/ext/alias-canon3.C new file mode 100644 index 00000000000..22e29e8ad58 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/alias-canon3.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// PR c++/66270 + +typedef float __m256 __attribute__ (( __vector_size__(32), __may_alias__ )); +struct A { + __m256 ymm; + const float &f() const; +}; + +const float &A::f() const { + return ymm[1]; +} diff --git a/gcc/tree.c b/gcc/tree.c index c22fa765f4c..ca48c60dd10 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7719,6 +7719,7 @@ build_pointer_type_for_mode (tree to_type, machine_mode mode, bool can_alias_all) { tree t; + bool could_alias = can_alias_all; if (to_type == error_mark_node) return error_mark_node; @@ -7756,7 +7757,7 @@ build_pointer_type_for_mode (tree to_type, machine_mode mode, if (TYPE_STRUCTURAL_EQUALITY_P (to_type)) SET_TYPE_STRUCTURAL_EQUALITY (t); - else if (TYPE_CANONICAL (to_type) != to_type) + else if (TYPE_CANONICAL (to_type) != to_type || could_alias) TYPE_CANONICAL (t) = build_pointer_type_for_mode (TYPE_CANONICAL (to_type), mode, false); @@ -7786,6 +7787,7 @@ build_reference_type_for_mode (tree to_type, machine_mode mode, bool can_alias_all) { tree t; + bool could_alias = can_alias_all; if (to_type == error_mark_node) return error_mark_node; @@ -7823,7 +7825,7 @@ build_reference_type_for_mode (tree to_type, machine_mode mode, if (TYPE_STRUCTURAL_EQUALITY_P (to_type)) SET_TYPE_STRUCTURAL_EQUALITY (t); - else if (TYPE_CANONICAL (to_type) != to_type) + else if (TYPE_CANONICAL (to_type) != to_type || could_alias) TYPE_CANONICAL (t) = build_reference_type_for_mode (TYPE_CANONICAL (to_type), mode, false);