]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix some Parallel Mode testsuite failures
authorJonathan Wakely <jwakely@redhat.com>
Thu, 3 Oct 2024 17:52:12 +0000 (18:52 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 4 Oct 2024 13:08:28 +0000 (14:08 +0100)
Some of these are due to no longer using #pragma GCC system_header in
libstdc++ headers, some have been failing for longer and weren't
noticed.

libstdc++-v3/ChangeLog:

* include/parallel/algobase.h (search): Use sequential algorithm
for constant evaluation.
* include/parallel/algorithmfwd.h (search): Add
_GLIBCXX20_CONSTEXPR.
* include/parallel/multiway_merge.h: Remove stray semi-colon.
* include/parallel/multiseq_selection.h: Add diagnostic pragmas
for -Wlong-long warning.
* include/parallel/quicksort.h: Likewise.
* include/parallel/random_number.h: Likewise.
* include/parallel/settings.h: Likewise.
* include/parallel/workstealing.h: Replace ++ and -- on volatile
variables.
* testsuite/17_intro/names.cc: Skip names defined by
<tr1/random>.
* testsuite/20_util/pair/dangling_ref.cc: Skip test if Parallel
Mode is enabled.
* testsuite/20_util/tuple/dangling_ref.cc: Likewise.

libstdc++-v3/include/parallel/algobase.h
libstdc++-v3/include/parallel/algorithmfwd.h
libstdc++-v3/include/parallel/multiseq_selection.h
libstdc++-v3/include/parallel/multiway_merge.h
libstdc++-v3/include/parallel/quicksort.h
libstdc++-v3/include/parallel/random_number.h
libstdc++-v3/include/parallel/settings.h
libstdc++-v3/include/parallel/workstealing.h
libstdc++-v3/testsuite/17_intro/names.cc
libstdc++-v3/testsuite/20_util/pair/dangling_ref.cc
libstdc++-v3/testsuite/20_util/tuple/dangling_ref.cc

index 67362f4ecaa3bc220bbed9c64c4f3f160c81aeba..b46ed610661ba5259c8104d3af6555e923084a7d 100644 (file)
@@ -515,11 +515,17 @@ namespace __parallel
   // Public interface
   template<typename _FIterator1, typename _FIterator2,
           typename _BinaryPredicate>
+    _GLIBCXX20_CONSTEXPR
     inline _FIterator1
     search(_FIterator1 __begin1, _FIterator1 __end1,
           _FIterator2 __begin2, _FIterator2 __end2,
           _BinaryPredicate  __pred)
     {
+#if __cplusplus > 201703L
+      if (std::is_constant_evaluated())
+       return _GLIBCXX_STD_A::search(__begin1, __end1, __begin2, __end2,
+                                     std::move(__pred));
+#endif
       return __search_switch(__begin1, __end1, __begin2, __end2, __pred,
                             std::__iterator_category(__begin1),
                             std::__iterator_category(__begin2));
index 476072b860ab0bc0e07183d382f950fe634cd2ea..7c9843ab161b687d43e9ed8c2683fc1c2a0f57e1 100644 (file)
@@ -353,6 +353,7 @@ namespace __parallel
            __gnu_parallel::sequential_tag);
 
   template<typename _FIter1, typename _FIter2, typename _BiPredicate>
+    _GLIBCXX20_CONSTEXPR
     _FIter1
     search(_FIter1, _FIter1, _FIter2, _FIter2, _BiPredicate);
 
index 22bd97e6432b3016eac39272099899c35f30c9b9..53264fd156b6a6516fa976521f21e9d040eaa7a9 100644 (file)
@@ -189,9 +189,12 @@ namespace __gnu_parallel
 
       __r = __rd_log2(__nmax) + 1;
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wlong-long" // LL literal
       // Pad all lists to this length, at least as long as any ns[__i],
       // equality iff __nmax = 2^__k - 1.
       __l = (1ULL << __r) - 1;
+#pragma GCC diagnostic pop
 
       for (_SeqNumber __i = 0; __i < __m; __i++)
         {
index e4bd004228280982f571f9877df1b17b22ce1294..d894e636a3e9b6d5198d0e30f8965aef32b99a7b 100644 (file)
@@ -2067,6 +2067,6 @@ namespace __gnu_parallel
        (__seqs_begin, __seqs_end, __target, __length, __comp,
         exact_tag(__tag.__get_num_threads()));
     }
-}; // namespace __gnu_parallel
+} // namespace __gnu_parallel
 
 #endif /* _GLIBCXX_PARALLEL_MULTIWAY_MERGE_H */
index a678b6d46906bc633085163e9d984938fb682dd1..c728cd91c24c9803b081f4c186545f1fb26a96d3 100644 (file)
@@ -66,12 +66,15 @@ namespace __gnu_parallel
       _ValueType* __samples = static_cast<_ValueType*>
        (::operator new(__num_samples * sizeof(_ValueType)));
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wlong-long" // LL literal
       for (_DifferenceType __s = 0; __s < __num_samples; ++__s)
         {
           const unsigned long long __index = static_cast<unsigned long long>
            (__s) * __n / __num_samples;
           ::new(&(__samples[__s])) _ValueType(__begin[__index]);
         }
+#pragma GCC diagnostic pop
 
       __gnu_sequential::sort(__samples, __samples + __num_samples, __comp);
 
index 8f8d9cd0651d90dac589e6a2b32853aaa5b465b3..0357fab79c891e6e519ba0caf6adc69a5cd5b18e 100644 (file)
@@ -38,6 +38,9 @@
 
 namespace __gnu_parallel
 {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wlong-long" // LL literal
+
   /** @brief Random number generator, based on the Mersenne twister. */
   class _RandomNumber
   {
@@ -120,6 +123,8 @@ namespace __gnu_parallel
     }
 };
 
+#pragma GCC diagnostic pop
+
 } // namespace __gnu_parallel
 
 #endif /* _GLIBCXX_PARALLEL_RANDOM_NUMBER_H */
index 1fbe458d583532465792f5695e80144ae91163a9..aac41649470586fd1a05563669de27d61288ad9c 100644 (file)
@@ -84,6 +84,9 @@
 
 #include <parallel/types.h>
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wlong-long" // LL literal
+
 /** 
   * @brief Determine at compile(?)-time if the parallel variant of an
   * algorithm should be called.
@@ -339,4 +342,6 @@ namespace __gnu_parallel
   };
 }
 
+#pragma GCC diagnostic pop
+
 #endif /* _GLIBCXX_PARALLEL_SETTINGS_H */
index f24d542d58b0f92885ddc871c8121f837277c48b..cd338fac455a0fcd835d32828e12396f350b20ca 100644 (file)
@@ -191,8 +191,8 @@ namespace __gnu_parallel
            // Cannot use volatile variable directly.
            _DifferenceType __my_first = __my_job._M_first;
            __result = __f(__op, __begin + __my_first);
-           ++__my_job._M_first;
-           --__my_job._M_load;
+           __my_job._M_first += 1;
+           __my_job._M_load -= 1;
          }
 
        _RAIter __current;
index 9b0ffcb50b2e07a5ff2c2bd480b9eecd402c78d3..6b9a3639aad42b43a94b3b7cd8fab3234ade89ef 100644 (file)
 #define n (
 #endif
 #define o (
-#if __cplusplus >= 201103L
+#if __cplusplus >= 201103L || defined(_GLIBCXX_PARALLEL)
 // <random> defines member functions called p()
+// (and <tr1/random> defines them too, which is included by Parallel Mode).
 #else
 #define p (
 #endif
 #define q (
 #define r (
-#if __cplusplus >= 201103L
+#if __cplusplus >= 201103L || defined(_GLIBCXX_PARALLEL)
 // <random> defines member functions called s() and t()
+// (and <tr1/random> defines them too, which is included by Parallel Mode).
 // <chrono> and <string> define operator ""s in C++14
 #else
 #define s (
index ca238f9cbd1eec0736fed051d13eb0d50e838f68..dcfccf18a033454c2fd3a477200a3ad16de8e6b1 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-do compile { target c++11 } }
 // { dg-options "-Wno-unused-variable" }
 // { dg-additional-options "-D_GLIBCXX_DEBUG" { target c++17_down } }
-
+// { dg-skip-if "cannot mix with DEBUG" { *-*-* } { "-D_GLIBCXX_PARALLEL" } }
 #include <utility>
 
 #if __cplusplus >= 202002L
index b2dcf35943852aee658ab8a11c652c0056a4bdd4..e7271a58a2f12b49e9a699be4d80e653e79c318a 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-do compile { target c++11 } }
 // { dg-options "-Wno-unused-variable" }
 // { dg-additional-options "-D_GLIBCXX_DEBUG" { target c++17_down } }
-
+// { dg-skip-if "cannot mix with DEBUG" { *-*-* } { "-D_GLIBCXX_PARALLEL" } }
 #include <tuple>
 #include <utility>