[gcc(refs/vendors/ARM/heads/arm-struct-reorg-wip)] Revert "tree: Don't reuse types if TYPE_USER_ALIGN differ [PR94775]"

Tamar Christina tnfchris@gcc.gnu.org
Fri Jul 17 14:56:05 GMT 2020


https://gcc.gnu.org/g:251c85372e088017e79894f50156901d112affee

commit 251c85372e088017e79894f50156901d112affee
Author: Marek Polacek <polacek@redhat.com>
Date:   Mon May 4 10:41:24 2020 -0400

    Revert "tree: Don't reuse types if TYPE_USER_ALIGN differ [PR94775]"
    
            Revert:
            2020-04-30  Marek Polacek  <polacek@redhat.com>
    
            PR c++/94775
            * tree.c (check_base_type): Return true only if TYPE_USER_ALIGN match.
            (check_aligned_type): Check if TYPE_USER_ALIGN match.

Diff:
---
 gcc/ChangeLog                                |  9 +++++++
 gcc/testsuite/g++.dg/warn/Warray-bounds-10.C | 40 ----------------------------
 gcc/tree.c                                   |  4 +--
 3 files changed, 10 insertions(+), 43 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 752dd84c9c1..f25256d189f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2020-05-04  Marek Polacek  <polacek@redhat.com>
+
+	Revert:
+	2020-04-30  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/94775
+	* tree.c (check_base_type): Return true only if TYPE_USER_ALIGN match.
+	(check_aligned_type): Check if TYPE_USER_ALIGN match.
+
 2020-05-02  Jakub Jelinek  <jakub@redhat.com>
 
 	* config/tilegx/tilegx.md
diff --git a/gcc/testsuite/g++.dg/warn/Warray-bounds-10.C b/gcc/testsuite/g++.dg/warn/Warray-bounds-10.C
deleted file mode 100644
index 0a18f637e0e..00000000000
--- a/gcc/testsuite/g++.dg/warn/Warray-bounds-10.C
+++ /dev/null
@@ -1,40 +0,0 @@
-// PR c++/94775
-// { dg-do compile { target c++14 } }
-// { dg-options "-O2 -Warray-bounds" }
-
-template <typename> using a = int;
-template <bool, typename, typename> using b = int;
-typedef char d;
-template <long> using e = int;
-template <int f, int q> struct h { using i = b<q, a<e<f>>, e<f>>; };
-template <long f, bool g> using j = typename h<f, g>::i;
-long ab, k, aj;
-const d l[]{};
-class m {
-public:
-  m(int);
-};
-class n {
-  void ad() const;
-  template <class ae> void o(long) const {
-    using c __attribute__((aligned(1))) = const ae;
-  }
-  long p;
-  template <class, class>
-  auto s(unsigned long, unsigned long, unsigned long, unsigned long) const;
-  template <bool = false> auto q(unsigned long, unsigned long) const;
-};
-template <class, class>
-auto n::s(unsigned long, unsigned long, unsigned long, unsigned long t) const {
-  o<d>(p);
-  return t;
-}
-template <bool g> auto n::q(unsigned long p1, unsigned long p2) const {
-  using r = j<4, false>;
-  using ai = j<4, g>;
-  return s<ai, r>(ab, k, p1, p2);
-}
-void n::ad() const {
-  long f(l[aj]); // { dg-warning "outside array bounds" }
-  m(q(8, f));
-}
diff --git a/gcc/tree.c b/gcc/tree.c
index 341766c51e5..e451401822c 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -6493,8 +6493,7 @@ check_base_type (const_tree cand, const_tree base)
 			        TYPE_ATTRIBUTES (base)))
     return false;
   /* Check alignment.  */
-  if (TYPE_ALIGN (cand) == TYPE_ALIGN (base)
-      && TYPE_USER_ALIGN (cand) == TYPE_USER_ALIGN (base))
+  if (TYPE_ALIGN (cand) == TYPE_ALIGN (base))
     return true;
   /* Atomic types increase minimal alignment.  We must to do so as well
      or we get duplicated canonical types. See PR88686.  */
@@ -6529,7 +6528,6 @@ check_aligned_type (const_tree cand, const_tree base, unsigned int align)
 	  && TYPE_CONTEXT (cand) == TYPE_CONTEXT (base)
 	  /* Check alignment.  */
 	  && TYPE_ALIGN (cand) == align
-	  && TYPE_USER_ALIGN (cand) == TYPE_USER_ALIGN (base)
 	  && attribute_list_equal (TYPE_ATTRIBUTES (cand),
 				   TYPE_ATTRIBUTES (base))
 	  && check_lang_type (cand, base));


More information about the Gcc-cvs mailing list