]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
wide-int: Fix build with gcc < 12 or clang++ [PR111787]
authorJakub Jelinek <jakub@redhat.com>
Thu, 12 Oct 2023 15:20:36 +0000 (17:20 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 12 Oct 2023 15:20:36 +0000 (17:20 +0200)
While my wide_int patch bootstrapped/regtested fine when I used GCC 12
as system gcc, apparently it doesn't with GCC 11 and older or clang++.
For GCC before PR96555 C++ DR1315 implementation the compiler complains
about template argument involving template parameters, for clang++ the
same + complains about missing needs_write_val_arg static data member
in some wi::int_traits specializations.

2023-10-12  Jakub Jelinek  <jakub@redhat.com>

PR bootstrap/111787
* tree.h (wi::int_traits <unextended_tree>::needs_write_val_arg): New
static data member.
(int_traits <extended_tree <N>>::needs_write_val_arg): Likewise.
(wi::ints_for): Provide separate partial specializations for
generic_wide_int <extended_tree <N>> and INL_CONST_PRECISION or that
and CONST_PRECISION, rather than using
int_traits <extended_tree <N> >::precision_type as the second template
argument.
* rtl.h (wi::int_traits <rtx_mode_t>::needs_write_val_arg): New
static data member.
* double-int.h (wi::int_traits <double_int>::needs_write_val_arg):
Likewise.

gcc/double-int.h
gcc/rtl.h
gcc/tree.h

index 5fe67026032fed424d3390a9284cf6c688cfbdb5..2bd492a44214ecfeec82a2062aa72b9657da807f 100644 (file)
@@ -442,6 +442,7 @@ namespace wi
   {
     static const enum precision_type precision_type = INL_CONST_PRECISION;
     static const bool host_dependent_precision = true;
+    static const bool needs_write_val_arg = false;
     static const unsigned int precision = HOST_BITS_PER_DOUBLE_INT;
     static unsigned int get_precision (const double_int &);
     static wi::storage_ref decompose (HOST_WIDE_INT *, unsigned int,
index 6850281af62a5d0ccfcc1f6b02d454998fbac571..e4b6cc0dbb559e944452c40ebffdd90aed849476 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2270,6 +2270,7 @@ namespace wi
     /* This ought to be true, except for the special case that BImode
        is canonicalized to STORE_FLAG_VALUE, which might be 1.  */
     static const bool is_sign_extended = false;
+    static const bool needs_write_val_arg = false;
     static unsigned int get_precision (const rtx_mode_t &);
     static wi::storage_ref decompose (HOST_WIDE_INT *, unsigned int,
                                      const rtx_mode_t &);
index e06a5c8dd31bdf4c541e93833f75388ed8ec9403..f7d2775ae15212a201c6592900ee40129bbc815f 100644 (file)
@@ -6237,6 +6237,7 @@ namespace wi
     static const enum precision_type precision_type = VAR_PRECISION;
     static const bool host_dependent_precision = false;
     static const bool is_sign_extended = false;
+    static const bool needs_write_val_arg = false;
   };
 
   template <int N>
@@ -6262,6 +6263,7 @@ namespace wi
       = N == ADDR_MAX_PRECISION ? INL_CONST_PRECISION : CONST_PRECISION;
     static const bool host_dependent_precision = false;
     static const bool is_sign_extended = true;
+    static const bool needs_write_val_arg = false;
     static const unsigned int precision = N;
   };
 
@@ -6293,8 +6295,14 @@ namespace wi
   tree_to_poly_wide_ref to_poly_wide (const_tree);
 
   template <int N>
-  struct ints_for <generic_wide_int <extended_tree <N> >,
-                  int_traits <extended_tree <N> >::precision_type>
+  struct ints_for <generic_wide_int <extended_tree <N> >, INL_CONST_PRECISION>
+  {
+    typedef generic_wide_int <extended_tree <N> > extended;
+    static extended zero (const extended &);
+  };
+
+  template <int N>
+  struct ints_for <generic_wide_int <extended_tree <N> >, CONST_PRECISION>
   {
     typedef generic_wide_int <extended_tree <N> > extended;
     static extended zero (const extended &);
@@ -6532,8 +6540,15 @@ wi::to_poly_wide (const_tree t)
 template <int N>
 inline generic_wide_int <wi::extended_tree <N> >
 wi::ints_for <generic_wide_int <wi::extended_tree <N> >,
-             wi::int_traits <wi::extended_tree <N> >::precision_type
-            >::zero (const extended &x)
+             wi::INL_CONST_PRECISION>::zero (const extended &x)
+{
+  return build_zero_cst (TREE_TYPE (x.get_tree ()));
+}
+
+template <int N>
+inline generic_wide_int <wi::extended_tree <N> >
+wi::ints_for <generic_wide_int <wi::extended_tree <N> >,
+             wi::CONST_PRECISION>::zero (const extended &x)
 {
   return build_zero_cst (TREE_TYPE (x.get_tree ()));
 }