Hi!

C++20, in particular https://wg21.link/P1120R0 paper voted into it,
deprecates various operations between enumerators from different enumeration
types etc., and as we've switched to -std=gnu++20 by default, this now
results in warnings or errors during stage2 and onwards.

The following patch should fix loongarch build.
Tested on x86_64 with a cross to loongarch, by doing
make clean; make -j32 CXXFLAGS='-g -std=gnu++20' in the gcc/ directory.

Ok for trunk?

2025-11-28  Jakub Jelinek  <[email protected]>

        * config/loongarch/loongarch.cc (loongarch_unspec_address_offset):
        Avoid arithmetics between enumerators from different enum types.
        (loongarch_call_tls_get_addr): Likewise.

--- gcc/config/loongarch/loongarch.cc.jj        2025-11-22 12:19:00.716733840 
+0100
+++ gcc/config/loongarch/loongarch.cc   2025-11-28 21:35:56.056179223 +0100
@@ -3003,7 +3003,7 @@ loongarch_unspec_address_offset (rtx bas
                                 enum loongarch_symbol_type symbol_type)
 {
   base = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, base),
-                        UNSPEC_ADDRESS_FIRST + symbol_type);
+                        UNSPEC_ADDRESS_FIRST + (int) symbol_type);
   if (offset != const0_rtx)
     base = gen_rtx_PLUS (Pmode, base, offset);
   return gen_rtx_CONST (Pmode, base);
@@ -3223,7 +3223,7 @@ loongarch_call_tls_get_addr (rtx sym, en
                  rtx sum = gen_rtx_UNSPEC (
                    Pmode, gen_rtvec (1, loongarch_tls_symbol),
                    UNSPEC_ADDRESS_FIRST
-                   + loongarch_classify_symbol (loongarch_tls_symbol));
+                   + (int) loongarch_classify_symbol (loongarch_tls_symbol));
                  set_unique_reg_note (get_last_insn (), REG_EQUAL, sum);
                }
              else


        Jakub

Reply via email to