From 795f6eb481797d514a68010fb98d0f67010e224e Mon Sep 17 00:00:00 2001
From: eabdullin
Date: Mon, 30 Sep 2024 13:50:45 +0000
Subject: [PATCH] import CS gcc-11.5.0-2.el9
---
.gcc.metadata | 2 +-
.gitignore | 2 +-
SOURCES/gcc11-libgfortran-flush.patch | 51 +++++++++
SOURCES/gcc11-libstdc++-docs.patch | 4 +-
SOURCES/gcc11-pr105157.patch | 105 ++++++++++++++++++
SOURCES/gcc11-pr111039.patch | 59 ----------
SOURCES/gcc11-pr111070.patch | 66 ------------
SOURCES/gcc11-pr113960.patch | 107 ++++++++++++++++++
SOURCES/gcc11-pr116034.patch | 65 +++++++++++
SOURCES/gcc11-testsuite-fixes-3.patch | 150 ++++++++++++++++++++++++++
SPECS/gcc.spec | 77 +++++++++++--
11 files changed, 550 insertions(+), 138 deletions(-)
create mode 100644 SOURCES/gcc11-libgfortran-flush.patch
create mode 100644 SOURCES/gcc11-pr105157.patch
delete mode 100644 SOURCES/gcc11-pr111039.patch
delete mode 100644 SOURCES/gcc11-pr111070.patch
create mode 100644 SOURCES/gcc11-pr113960.patch
create mode 100644 SOURCES/gcc11-pr116034.patch
create mode 100644 SOURCES/gcc11-testsuite-fixes-3.patch
diff --git a/.gcc.metadata b/.gcc.metadata
index 49ef7d0..cefdc61 100644
--- a/.gcc.metadata
+++ b/.gcc.metadata
@@ -1,4 +1,4 @@
-0a97442f00d814b259be1da178f627b0e3690051 SOURCES/gcc-11.4.1-20231218.tar.xz
+fdeaf702eb50579d38faf7dc2aadbf5e27a2c432 SOURCES/gcc-11.5.0-20240719.tar.xz
bbffc5a2b05e4f0c97e882f96c448504491dc4ed SOURCES/isl-0.18.tar.bz2
6ec33952e824e837fef0e829c93d39d6a507082f SOURCES/newlib-cygwin-50e2a63b04bdd018484605fbb954fd1bd5147fa0.tar.xz
0e0c6f8d68ab0878f02287ac082c1077c831cd81 SOURCES/nvptx-tools-5f6f343a302d620b0868edab376c00b15741e39e.tar.xz
diff --git a/.gitignore b/.gitignore
index 557a2c5..94b3d9f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-SOURCES/gcc-11.4.1-20231218.tar.xz
+SOURCES/gcc-11.5.0-20240719.tar.xz
SOURCES/isl-0.18.tar.bz2
SOURCES/newlib-cygwin-50e2a63b04bdd018484605fbb954fd1bd5147fa0.tar.xz
SOURCES/nvptx-tools-5f6f343a302d620b0868edab376c00b15741e39e.tar.xz
diff --git a/SOURCES/gcc11-libgfortran-flush.patch b/SOURCES/gcc11-libgfortran-flush.patch
new file mode 100644
index 0000000..8e3016a
--- /dev/null
+++ b/SOURCES/gcc11-libgfortran-flush.patch
@@ -0,0 +1,51 @@
+commit c14f38d4292ec22462a4080841d526f87428130a
+Author: Francois-Xavier Coudert
+Date: Thu Dec 16 15:33:17 2021 +0100
+
+ Fix FLUSH IOSTAT value
+
+ PR libfortran/101255
+
+ libgfortran/ChangeLog:
+
+ * io/file_pos.c: Fix error code.
+
+ gcc/testsuite/ChangeLog:
+
+ * gfortran.dg/iostat_5.f90: New file.
+
+diff --git a/gcc/testsuite/gfortran.dg/iostat_5.f90 b/gcc/testsuite/gfortran.dg/iostat_5.f90
+new file mode 100644
+index 00000000000..1e72dfdf7e1
+--- /dev/null
++++ b/gcc/testsuite/gfortran.dg/iostat_5.f90
+@@ -0,0 +1,16 @@
++! PR libfortran/101255
++! { dg-do run }
++
++program test
++ use ISO_FORTRAN_ENV, only: IOSTAT_EOR, IOSTAT_END
++ implicit none
++ character(len=50) :: err
++ integer :: i
++
++ err = ""
++ flush(99, iostat=i, iomsg=err)
++
++ if (err == "") stop 1
++ if (i >= 0) stop 2
++ if (i == IOSTAT_EOR .or. i == IOSTAT_END) stop 3
++end
+diff --git a/libgfortran/io/file_pos.c b/libgfortran/io/file_pos.c
+index 7e71ca577e0..4ed1698f17a 100644
+--- a/libgfortran/io/file_pos.c
++++ b/libgfortran/io/file_pos.c
+@@ -527,7 +527,7 @@ st_flush (st_parameter_filepos *fpp)
+ }
+ else
+ /* FLUSH on unconnected unit is illegal: F95 std., 9.3.5. */
+- generate_error (&fpp->common, LIBERROR_BAD_OPTION,
++ generate_error (&fpp->common, -LIBERROR_BAD_UNIT,
+ "Specified UNIT in FLUSH is not connected");
+
+ if (needs_unlock)
diff --git a/SOURCES/gcc11-libstdc++-docs.patch b/SOURCES/gcc11-libstdc++-docs.patch
index 353ab27..b0f7deb 100644
--- a/SOURCES/gcc11-libstdc++-docs.patch
+++ b/SOURCES/gcc11-libstdc++-docs.patch
@@ -4,7 +4,7 @@
FSF
-+ Release 11.4.1
++ Release 11.5.0
+
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation
@@ -17,7 +17,7 @@
- The API documentation, rendered into HTML, can be viewed online
+ The API documentation, rendered into HTML, can be viewed locally
-+ for the 11.4.1 release,
++ for the 11.5.0 release,
+ online
for each GCC release
and
diff --git a/SOURCES/gcc11-pr105157.patch b/SOURCES/gcc11-pr105157.patch
new file mode 100644
index 0000000..79cac28
--- /dev/null
+++ b/SOURCES/gcc11-pr105157.patch
@@ -0,0 +1,105 @@
+The original patch had
+#define TARGET_CPU_NBITS 8
+but I've changed it to
+#define TARGET_CPU_NBITS 7
+
+commit 5522dec054cb940fe83661b96249aa12c54c1d77
+Author: Andre Vieira
+Date: Fri Apr 8 15:12:23 2022 +0100
+
+ aarch64: PR target/105157 Increase number of cores TARGET_CPU_DEFAULT can encode
+
+ This addresses the compile-time increase seen in the PR target/105157. This was
+ being caused by selecting the wrong core tuning, as when we added the latest
+ AArch64 the TARGET_CPU_generic tuning was pushed beyond the 0x3f mask we used
+ to encode both target cpu and attributes into TARGET_CPU_DEFAULT.
+
+ gcc/ChangeLog:
+
+ PR target/105157
+ * config.gcc: Shift ext_mask by TARGET_CPU_NBITS.
+ * config/aarch64/aarch64.h (TARGET_CPU_NBITS): New macro.
+ (TARGET_CPU_MASK): Likewise.
+ (TARGET_CPU_DEFAULT): Use TARGET_CPU_NBITS.
+ * config/aarch64/aarch64.cc (aarch64_get_tune_cpu): Use TARGET_CPU_MASK.
+ (aarch64_get_arch): Likewise.
+ (aarch64_override_options): Use TARGET_CPU_NBITS.
+
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -4261,7 +4261,7 @@ case "${target}" in
+ ext_val=`echo $ext_val | sed -e 's/[a-z0-9]\+//'`
+ done
+
+- ext_mask="(("$ext_mask") << 6)"
++ ext_mask="(("$ext_mask") << TARGET_CPU_NBITS)"
+ if [ x"$base_id" != x ]; then
+ target_cpu_cname="TARGET_CPU_$base_id | $ext_mask"
+ fi
+--- a/gcc/config/aarch64/aarch64.c
++++ b/gcc/config/aarch64/aarch64.c
+@@ -18053,6 +18053,9 @@ aarch64_validate_mtune (const char *str, const struct processor **res)
+ return false;
+ }
+
++static_assert (TARGET_CPU_generic < TARGET_CPU_MASK,
++ "TARGET_CPU_NBITS is big enough");
++
+ /* Return the CPU corresponding to the enum CPU.
+ If it doesn't specify a cpu, return the default. */
+
+@@ -18062,12 +18065,12 @@ aarch64_get_tune_cpu (enum aarch64_processor cpu)
+ if (cpu != aarch64_none)
+ return &all_cores[cpu];
+
+- /* The & 0x3f is to extract the bottom 6 bits that encode the
+- default cpu as selected by the --with-cpu GCC configure option
++ /* The & TARGET_CPU_MASK is to extract the bottom TARGET_CPU_NBITS bits that
++ encode the default cpu as selected by the --with-cpu GCC configure option
+ in config.gcc.
+ ???: The whole TARGET_CPU_DEFAULT and AARCH64_CPU_DEFAULT_FLAGS
+ flags mechanism should be reworked to make it more sane. */
+- return &all_cores[TARGET_CPU_DEFAULT & 0x3f];
++ return &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK];
+ }
+
+ /* Return the architecture corresponding to the enum ARCH.
+@@ -18079,7 +18082,8 @@ aarch64_get_arch (enum aarch64_arch arch)
+ if (arch != aarch64_no_arch)
+ return &all_architectures[arch];
+
+- const struct processor *cpu = &all_cores[TARGET_CPU_DEFAULT & 0x3f];
++ const struct processor *cpu
++ = &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK];
+
+ return &all_architectures[cpu->arch];
+ }
+@@ -18166,7 +18170,7 @@ aarch64_override_options (void)
+ {
+ /* Get default configure-time CPU. */
+ selected_cpu = aarch64_get_tune_cpu (aarch64_none);
+- aarch64_isa_flags = TARGET_CPU_DEFAULT >> 6;
++ aarch64_isa_flags = TARGET_CPU_DEFAULT >> TARGET_CPU_NBITS;
+ }
+
+ if (selected_tune)
+--- a/gcc/config/aarch64/aarch64.h
++++ b/gcc/config/aarch64/aarch64.h
+@@ -813,10 +813,16 @@ enum target_cpus
+ TARGET_CPU_generic
+ };
+
++/* Define how many bits are used to represent the CPU in TARGET_CPU_DEFAULT.
++ This needs to be big enough to fit the value of TARGET_CPU_generic.
++ All bits after this are used to represent the AARCH64_CPU_DEFAULT_FLAGS. */
++#define TARGET_CPU_NBITS 7
++#define TARGET_CPU_MASK ((1 << TARGET_CPU_NBITS) - 1)
++
+ /* If there is no CPU defined at configure, use generic as default. */
+ #ifndef TARGET_CPU_DEFAULT
+ #define TARGET_CPU_DEFAULT \
+- (TARGET_CPU_generic | (AARCH64_CPU_DEFAULT_FLAGS << 6))
++ (TARGET_CPU_generic | (AARCH64_CPU_DEFAULT_FLAGS << TARGET_CPU_NBITS))
+ #endif
+
+ /* If inserting NOP before a mult-accumulate insn remember to adjust the
diff --git a/SOURCES/gcc11-pr111039.patch b/SOURCES/gcc11-pr111039.patch
deleted file mode 100644
index 3fab07e..0000000
--- a/SOURCES/gcc11-pr111039.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-commit 482551a79a3d3f107f6239679ee74655cfe8707e
-Author: Richard Biener
-Date: Thu Aug 17 13:10:14 2023 +0200
-
- tree-optimization/111039 - abnormals and bit test merging
-
- The following guards the bit test merging code in if-combine against
- the appearance of SSA names used in abnormal PHIs.
-
- PR tree-optimization/111039
- * tree-ssa-ifcombine.cc (ifcombine_ifandif): Check for
- SSA_NAME_OCCURS_IN_ABNORMAL_PHI.
-
- * gcc.dg/pr111039.c: New testcase.
-
-diff --git a/gcc/testsuite/gcc.dg/pr111039.c b/gcc/testsuite/gcc.dg/pr111039.c
-new file mode 100644
-index 00000000000..bec9983b35f
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/pr111039.c
-@@ -0,0 +1,15 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O" } */
-+
-+int _setjmp ();
-+void abcd ();
-+void abcde ();
-+void compiler_corruption_function(int flags)
-+{
-+ int nowait = flags & 1048576, isexpand = flags & 8388608;
-+ abcd();
-+ _setjmp(flags);
-+ if (nowait && isexpand)
-+ flags &= 0;
-+ abcde();
-+}
---- a/gcc/tree-ssa-ifcombine.c
-+++ b/gcc/tree-ssa-ifcombine.c
-@@ -430,6 +430,9 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv,
- {
- tree t, t2;
-
-+ if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1))
-+ return false;
-+
- /* Do it. */
- gsi = gsi_for_stmt (inner_cond);
- t = fold_build2 (LSHIFT_EXPR, TREE_TYPE (name1),
-@@ -486,6 +489,10 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv,
- gimple_stmt_iterator gsi;
- tree t;
-
-+ if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1)
-+ || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name2))
-+ return false;
-+
- /* Find the common name which is bit-tested. */
- if (name1 == name2)
- ;
diff --git a/SOURCES/gcc11-pr111070.patch b/SOURCES/gcc11-pr111070.patch
deleted file mode 100644
index b5a0241..0000000
--- a/SOURCES/gcc11-pr111070.patch
+++ /dev/null
@@ -1,66 +0,0 @@
-commit 966b0a96523fb7adbf498ac71df5e033c70dc546
-Author: Richard Biener
-Date: Mon Aug 21 09:01:00 2023 +0200
-
- tree-optimization/111070 - fix ICE with recent ifcombine fix
-
- We now got test coverage for non-SSA name bits so the following amends
- the SSA_NAME_OCCURS_IN_ABNORMAL_PHI checks.
-
- PR tree-optimization/111070
- * tree-ssa-ifcombine.cc (ifcombine_ifandif): Check we have
- an SSA name before checking SSA_NAME_OCCURS_IN_ABNORMAL_PHI.
-
- * gcc.dg/pr111070.c: New testcase.
-
-diff --git a/gcc/testsuite/gcc.dg/pr111070.c b/gcc/testsuite/gcc.dg/pr111070.c
-new file mode 100644
-index 00000000000..1ebc7adf782
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/pr111070.c
-@@ -0,0 +1,20 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O" } */
-+
-+/* common */
-+char c;
-+/* arrays must be 8 byte aligned, regardless of size */
-+char c_ary[1];
-+
-+/* data */
-+char d = 1;
-+char d_ary[1] = {1};
-+
-+int main ()
-+{
-+ if (((unsigned long)&c_ary[0] & 7) != 0)
-+ return 1;
-+ if (((unsigned long)&d_ary[0] & 7) != 0)
-+ return 1;
-+ return 0;
-+}
---- a/gcc/tree-ssa-ifcombine.c
-+++ b/gcc/tree-ssa-ifcombine.c
-@@ -430,7 +430,8 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv,
- {
- tree t, t2;
-
-- if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1))
-+ if (TREE_CODE (name1) == SSA_NAME
-+ && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1))
- return false;
-
- /* Do it. */
-@@ -489,8 +490,10 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv,
- gimple_stmt_iterator gsi;
- tree t;
-
-- if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1)
-- || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name2))
-+ if ((TREE_CODE (name1) == SSA_NAME
-+ && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1))
-+ || (TREE_CODE (name2) == SSA_NAME
-+ && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name2)))
- return false;
-
- /* Find the common name which is bit-tested. */
diff --git a/SOURCES/gcc11-pr113960.patch b/SOURCES/gcc11-pr113960.patch
new file mode 100644
index 0000000..b9ca081
--- /dev/null
+++ b/SOURCES/gcc11-pr113960.patch
@@ -0,0 +1,107 @@
+commit 6f5dcea85a31845ec6f4b6886734b0f02e013718
+Author: Jonathan Wakely
+Date: Tue Feb 27 17:50:34 2024 +0000
+
+ libstdc++: Fix conditions for using memcmp in std::lexicographical_compare_three_way [PR113960]
+
+ The change in r11-2981-g2f983fa69005b6 meant that
+ std::lexicographical_compare_three_way started to use memcmp for
+ unsigned integers on big endian targets, but for that to be valid we
+ need the two value types to have the same size and we need to use that
+ size to compute the length passed to memcmp.
+
+ I already defined a __is_memcmp_ordered_with trait that does the right
+ checks, std::lexicographical_compare_three_way just needs to use it.
+
+ libstdc++-v3/ChangeLog:
+
+ PR libstdc++/113960
+ * include/bits/stl_algobase.h (__is_byte_iter): Replace with ...
+ (__memcmp_ordered_with): New concept.
+ (lexicographical_compare_three_way): Use __memcmp_ordered_with
+ instead of __is_byte_iter. Use correct length for memcmp.
+ * testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc:
+ New test.
+
+ (cherry picked from commit f5cdda8acb06c20335855ed353ab9a441c12128a)
+
+diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
+index 7664301a208..6e648e48ad0 100644
+--- a/libstdc++-v3/include/bits/stl_algobase.h
++++ b/libstdc++-v3/include/bits/stl_algobase.h
+@@ -1780,11 +1780,14 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
+ }
+
+ #if __cpp_lib_three_way_comparison
+- // Iter points to a contiguous range of unsigned narrow character type
+- // or std::byte, suitable for comparison by memcmp.
+- template
+- concept __is_byte_iter = contiguous_iterator<_Iter>
+- && __is_memcmp_ordered>::__value;
++ // Both iterators refer to contiguous ranges of unsigned narrow characters,
++ // or std::byte, or big-endian unsigned integers, suitable for comparison
++ // using memcmp.
++ template
++ concept __memcmp_ordered_with
++ = (__is_memcmp_ordered_with,
++ iter_value_t<_Iter2>>::__value)
++ && contiguous_iterator<_Iter1> && contiguous_iterator<_Iter2>;
+
+ // Return a struct with two members, initialized to the smaller of x and y
+ // (or x if they compare equal) and the result of the comparison x <=> y.
+@@ -1834,20 +1837,20 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
+ if (!std::is_constant_evaluated())
+ if constexpr (same_as<_Comp, __detail::_Synth3way>
+ || same_as<_Comp, compare_three_way>)
+- if constexpr (__is_byte_iter<_InputIter1>)
+- if constexpr (__is_byte_iter<_InputIter2>)
+- {
+- const auto [__len, __lencmp] = _GLIBCXX_STD_A::
+- __min_cmp(__last1 - __first1, __last2 - __first2);
+- if (__len)
+- {
+- const auto __c
+- = __builtin_memcmp(&*__first1, &*__first2, __len) <=> 0;
+- if (__c != 0)
+- return __c;
+- }
+- return __lencmp;
+- }
++ if constexpr (__memcmp_ordered_with<_InputIter1, _InputIter2>)
++ {
++ const auto [__len, __lencmp] = _GLIBCXX_STD_A::
++ __min_cmp(__last1 - __first1, __last2 - __first2);
++ if (__len)
++ {
++ const auto __blen = __len * sizeof(*__first1);
++ const auto __c
++ = __builtin_memcmp(&*__first1, &*__first2, __blen) <=> 0;
++ if (__c != 0)
++ return __c;
++ }
++ return __lencmp;
++ }
+ #endif // is_constant_evaluated
+ while (__first1 != __last1)
+ {
+diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc
+new file mode 100644
+index 00000000000..d51ae1a3d50
+--- /dev/null
++++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc
+@@ -0,0 +1,15 @@
++// { dg-do run { target c++20 } }
++
++// PR libstdc++/113960
++// std::map with std::vector as input overwrites itself with c++20, on s390x
++
++#include
++#include
++
++int main()
++{
++ unsigned short a1[] { 1, 2, 3 };
++ unsigned short a2[] { 1, 2, 4 };
++ // Incorrect memcmp comparison for big endian targets.
++ VERIFY( std::lexicographical_compare_three_way(a1, a1+3, a2, a2+3) < 0 );
++}
diff --git a/SOURCES/gcc11-pr116034.patch b/SOURCES/gcc11-pr116034.patch
new file mode 100644
index 0000000..1f194de
--- /dev/null
+++ b/SOURCES/gcc11-pr116034.patch
@@ -0,0 +1,65 @@
+commit 084768c865cd50a6f7ff177db2dbdbb7aadaeee0
+Author: Jakub Jelinek
+Date: Tue Jul 23 10:50:29 2024 +0200
+
+ ssa: Fix up maybe_rewrite_mem_ref_base complex type handling [PR116034]
+
+ The folding into REALPART_EXPR is correct, used only when the mem_offset
+ is zero, but for IMAGPART_EXPR it didn't check the exact offset value (just
+ that it is not 0).
+ The following patch fixes that by using IMAGPART_EXPR only if the offset
+ is right and using BITFIELD_REF or whatever else otherwise.
+
+ 2024-07-23 Jakub Jelinek
+ Andrew Pinski
+
+ PR tree-optimization/116034
+ * tree-ssa.c (maybe_rewrite_mem_ref_base): Only use IMAGPART_EXPR
+ if MEM_REF offset is equal to element type size.
+
+ * gcc.dg/pr116034.c: New test.
+
+ (cherry picked from commit b9cefd67a2a464a3c9413e6b3f28e7dc7a9ef162)
+
+diff --git a/gcc/testsuite/gcc.dg/pr116034.c b/gcc/testsuite/gcc.dg/pr116034.c
+new file mode 100644
+index 00000000000..9a31de03424
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/pr116034.c
+@@ -0,0 +1,22 @@
++/* PR tree-optimization/116034 */
++/* { dg-do run } */
++/* { dg-options "-O1 -fno-strict-aliasing" } */
++
++int g;
++
++static inline int
++foo (_Complex unsigned short c)
++{
++ __builtin_memmove (&g, 1 + (char *) &c, 2);
++ return g;
++}
++
++int
++main ()
++{
++ if (__SIZEOF_SHORT__ == 2
++ && __CHAR_BIT__ == 8
++ && (foo (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ ? 0x100 : 1)
++ != (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ ? 1 : 0x100)))
++ __builtin_abort ();
++}
+--- a/gcc/tree-ssa.c
++++ b/gcc/tree-ssa.c
+@@ -1506,7 +1506,10 @@ maybe_rewrite_mem_ref_base (tree *tp, bitmap suitable_for_renaming)
+ }
+ else if (TREE_CODE (TREE_TYPE (sym)) == COMPLEX_TYPE
+ && useless_type_conversion_p (TREE_TYPE (*tp),
+- TREE_TYPE (TREE_TYPE (sym))))
++ TREE_TYPE (TREE_TYPE (sym)))
++ && (integer_zerop (TREE_OPERAND (*tp, 1))
++ || tree_int_cst_equal (TREE_OPERAND (*tp, 1),
++ TYPE_SIZE_UNIT (TREE_TYPE (*tp)))))
+ {
+ *tp = build1 (integer_zerop (TREE_OPERAND (*tp, 1))
+ ? REALPART_EXPR : IMAGPART_EXPR,
diff --git a/SOURCES/gcc11-testsuite-fixes-3.patch b/SOURCES/gcc11-testsuite-fixes-3.patch
new file mode 100644
index 0000000..25ea3a9
--- /dev/null
+++ b/SOURCES/gcc11-testsuite-fixes-3.patch
@@ -0,0 +1,150 @@
+commit f1b1d515aa5836844cdb45e8bb2b941784f78fd2
+Author: Jakub Jelinek
+Date: Mon Apr 22 18:00:06 2024 +0200
+
+ libstdc++: Workaround kernel-headers on s390x-linux
+
+ We see
+ FAIL: 17_intro/headers/c++1998/all_attributes.cc (test for excess errors)
+ FAIL: 17_intro/headers/c++2011/all_attributes.cc (test for excess errors)
+ FAIL: 17_intro/headers/c++2014/all_attributes.cc (test for excess errors)
+ FAIL: 17_intro/headers/c++2017/all_attributes.cc (test for excess errors)
+ FAIL: 17_intro/headers/c++2020/all_attributes.cc (test for excess errors)
+ FAIL: 17_intro/names.cc -std=gnu++17 (test for excess errors)
+ on s390x-linux.
+ The first 5 are due to kernel-headers not using uglified attribute names,
+ where contains
+ __attribute__((packed, aligned(4)))
+ I've filed a downstream bugreport for this in
+ https://bugzilla.redhat.com/show_bug.cgi?id=2276084
+ (not really sure where to report kernel-headers issues upstream), while the
+ last one is due to from glibc containing:
+ #ifdef __USE_MISC
+ # define __ctx(fld) fld
+ #else
+ # define __ctx(fld) __ ## fld
+ #endif
+ ...
+ typedef union
+ {
+ double __ctx(d);
+ float __ctx(f);
+ } fpreg_t;
+ and g++ predefining -D_GNU_SOURCE which implies define __USE_MISC.
+
+ The following patch adds a workaround for this on the libstdc++ testsuite
+ side.
+
+ 2024-04-22 Jakub Jelinek
+
+ * testsuite/17_intro/names.cc (d, f): Undefine on s390*-linux*.
+ * testsuite/17_intro/headers/c++1998/all_attributes.cc (packed): Don't
+ define on s390.
+ * testsuite/17_intro/headers/c++2011/all_attributes.cc (packed):
+ Likewise.
+ * testsuite/17_intro/headers/c++2014/all_attributes.cc (packed):
+ Likewise.
+ * testsuite/17_intro/headers/c++2017/all_attributes.cc (packed):
+ Likewise.
+ * testsuite/17_intro/headers/c++2020/all_attributes.cc (packed):
+ Likewise.
+
+ (cherry picked from commit cf5f7791056b3ed993bc8024be767a86157514a9)
+
+diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc
+index 74268b6a482..658063bd0a4 100644
+--- a/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc
++++ b/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc
+@@ -29,7 +29,11 @@
+ # define noreturn 1
+ # define visibility 1
+ #endif
++#ifndef __s390__
++// kernel-headers uses __attribute__((packed,aligned(4))) on
++// S390.
+ #define packed 1
++#endif
+ #define pure 1
+ // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
+ #ifndef __arm__
+diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc
+index 5d0c5fe8177..f1bcc1fbbc8 100644
+--- a/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc
++++ b/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc
+@@ -29,7 +29,11 @@
+ # define visibility 1
+ #endif
+ #define no_unique_address 1
++#ifndef __s390__
++// kernel-headers uses __attribute__((packed,aligned(4))) on
++// S390.
+ #define packed 1
++#endif
+ #define pure 1
+ // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
+ #ifndef __arm__
+diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc
+index 3cac2190ec7..48e7ef64afb 100644
+--- a/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc
++++ b/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc
+@@ -29,7 +29,11 @@
+ # define visibility 1
+ #endif
+ #define no_unique_address 1
++#ifndef __s390__
++// kernel-headers uses __attribute__((packed,aligned(4))) on
++// S390.
+ #define packed 1
++#endif
+ #define pure 1
+ // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
+ #ifndef __arm__
+diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc
+index f607532aa90..03e4e23c686 100644
+--- a/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc
++++ b/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc
+@@ -28,7 +28,11 @@
+ # define visibility 1
+ #endif
+ #define no_unique_address 1
++#ifndef __s390__
++// kernel-headers uses __attribute__((packed,aligned(4))) on
++// S390.
+ #define packed 1
++#endif
+ #define pure 1
+ // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
+ #ifndef __arm__
+diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc
+index 5732633c7e4..7375dc88bb1 100644
+--- a/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc
++++ b/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc
+@@ -27,7 +27,11 @@
+ # define cold 1
+ # define visibility 1
+ #endif
++#ifndef __s390__
++// kernel-headers uses __attribute__((packed,aligned(4))) on
++// S390.
+ #define packed 1
++#endif
+ #define pure 1
+ // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
+ #ifndef __arm__
+diff --git a/libstdc++-v3/testsuite/17_intro/names.cc b/libstdc++-v3/testsuite/17_intro/names.cc
+index eb4d064177c..864bc20f146 100644
+--- a/libstdc++-v3/testsuite/17_intro/names.cc
++++ b/libstdc++-v3/testsuite/17_intro/names.cc
+@@ -267,6 +267,12 @@
+ #undef u
+ #endif
+
++#if defined (__linux__) && defined (__s390__)
++// defines fpreg_t::d and fpreg_t::f
++#undef d
++#undef f
++#endif
++
+ #if defined (__linux__) && defined (__sparc__)
+ #undef y
+ #endif
diff --git a/SPECS/gcc.spec b/SPECS/gcc.spec
index 16cfbb6..c8fed28 100644
--- a/SPECS/gcc.spec
+++ b/SPECS/gcc.spec
@@ -1,10 +1,10 @@
-%global DATE 20231218
-%global gitrev 9e6808abff4d96f3f09474a2a744ef5f56df3e28
-%global gcc_version 11.4.1
+%global DATE 20240719
+%global gitrev a985e3068a6f8045f8a6f2d2d5ae75f5eb0a8767
+%global gcc_version 11.5.0
%global gcc_major 11
# Note, gcc_release must be integer, if you want to add suffixes to
# %%{release}, append them after %%{gcc_release} on Release: line.
-%global gcc_release 3
+%global gcc_release 2
%global nvptx_tools_gitrev 5f6f343a302d620b0868edab376c00b15741e39e
%global newlib_cygwin_gitrev 50e2a63b04bdd018484605fbb954fd1bd5147fa0
%global _unpackaged_files_terminate_build 0
@@ -292,9 +292,12 @@ Patch28: gcc11-s390x-regarg-2.patch
Patch29: gcc11-s390x-regarg-3.patch
Patch30: gcc11-testsuite-fixes.patch
Patch32: gcc11-testsuite-fixes-2.patch
-Patch33: gcc11-pr111039.patch
-Patch34: gcc11-pr111070.patch
+Patch33: gcc11-testsuite-fixes-3.patch
+Patch34: gcc11-pr116034.patch
Patch35: gcc11-testsuite-aarch64-add-fno-stack-protector.patch
+Patch36: gcc11-libgfortran-flush.patch
+Patch37: gcc11-pr113960.patch
+Patch38: gcc11-pr105157.patch
Patch100: gcc11-fortran-fdec-duplicates.patch
Patch101: gcc11-fortran-flogical-as-integer.patch
@@ -892,9 +895,12 @@ mark them as cross compiled.
%patch29 -p1 -b .s390x-regarg-3~
%patch30 -p1 -b .testsuite~
%patch32 -p1 -b .testsuite2~
-%patch33 -p1 -b .pr111039~
-%patch34 -p1 -b .pr111070~
-%patch35 -p1 -b .testsuite3~
+%patch33 -p1 -b .testsuite3~
+%patch34 -p1 -b .pr116034~
+%patch35 -p1 -b .testsuite4~
+%patch36 -p1 -b .libgfortran-flush~
+%patch37 -p1 -b .pr113960~
+%patch38 -p1 -b .pr105157~
%if 0%{?rhel} >= 9
%patch100 -p1 -b .fortran-fdec-duplicates~
@@ -3588,6 +3594,59 @@ end
%endif
%changelog
+* Mon Jul 22 2024 Marek Polacek 11.5.0-2
+- fix TARGET_CPU_DEFAULT (PR target/105157, RHEL-50037)
+- libstdc++: Workaround kernel-headers on s390x-linux (RHEL-50054)
+- fix wrong code with memcpy from _Complex (PR tree-optimization/116034)
+
+* Fri Jul 19 2024 Marek Polacek 11.5.0-1
+- update from releases/gcc-11 branch (RHEL-35635)
+ - GCC 11.5 release
+ - PRs ada/113893, ada/113979, analyzer/104042, c/113262, c/114007, c/114493,
+ c++/89224, c++/92145, c++/92407, c++/97990, c++/99710, c++/100667,
+ c++/100772, c++/101765, c++/103185, c++/104051, c++/111485,
+ c++/111529, c++/113598, c++/113674, c++/114537, c++/114561,
+ c++/114562, c++/114572, c++/114634, c++/114691, d/113125, d/113758,
+ d/114171, debug/111080, debug/112718, driver/115440, fortran/50410,
+ fortran/103715, fortran/104908, fortran/107426, fortran/114474,
+ fortran/114825, gcov-profile/114115, libfortran/110651,
+ libgomp/113192, libquadmath/114533, libstdc++/104259,
+ libstdc++/104606, libstdc++/105417, libstdc++/110054,
+ libstdc++/113250, libstdc++/114147, libstdc++/114401,
+ libstdc++/114750, libstdc++/114803, libstdc++/115269,
+ libstdc++/115454, libstdc++/115575, middle-end/90348,
+ middle-end/95351, middle-end/107385, middle-end/108789,
+ middle-end/110027, middle-end/110115, middle-end/110176,
+ middle-end/111422, middle-end/111632, middle-end/112732,
+ middle-end/113907, middle-end/113921, middle-end/114599,
+ middle-end/114734, middle-end/114753, middle-end/115527,
+ middle-end/115836, objc/101666, objc/101718, preprocessor/105608,
+ rtl-optimization/100303, rtl-optimization/108086,
+ rtl-optimization/110079, rtl-optimization/114768,
+ rtl-optimization/114902, rtl-optimization/115092, sanitizer/97696,
+ sanitizer/111736, sanitizer/114956, sanitizer/115172, target/88309,
+ target/101737, target/101865, target/105522, target/108120,
+ target/108743, target/110411, target/111610, target/111677,
+ target/112397, target/113122, target/113281, target/114049,
+ target/114098, target/114130, target/114184, target/114310,
+ target/114837, target/114846, target/115253, target/115297,
+ target/115360, target/115457, target/115475, target/115611,
+ target/115691, testsuite/113175, testsuite/114034, testsuite/114036,
+ tree-optimization/110386, tree-optimization/110422,
+ tree-optimization/111039, tree-optimization/111070,
+ tree-optimization/111331, tree-optimization/111407,
+ tree-optimization/111445, tree-optimization/111736,
+ tree-optimization/112495, tree-optimization/112505,
+ tree-optimization/112793, tree-optimization/113372,
+ tree-optimization/113552, tree-optimization/113603,
+ tree-optimization/114027, tree-optimization/114115,
+ tree-optimization/114566, tree-optimization/114876,
+ tree-optimization/115192, tree-optimization/115337,
+ tree-optimization/115843
+- fix FLUSH IOSTAT value (PR libfortran/101255, RHEL-32536)
+- fix conditions for using memcmp in
+ std::lexicographical_compare_three_way (PR libstdc++/113960)
+
* Mon Dec 18 2023 Marek Polacek 11.4.1-3
- update from releases/gcc-11-branch (RHEL-17638)
- PRs c++/106310, c++/106890, c++/109666, c++/109761, c++/111357,