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 powerpc, by doing
make clean; make -j32 CXXFLAGS='-g -std=gnu++20' in the gcc/ directory.

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

        * config/rs6000/rs6000.cc (complex_multiply_builtin_code):
        Avoid arithmetics between enumerators from different enum types.
        (complex_divide_builtin_code): Likewise.

--- gcc/config/rs6000/rs6000.cc.jj      2025-10-09 17:50:03.359651422 +0200
+++ gcc/config/rs6000/rs6000.cc 2025-11-28 21:56:27.230568674 +0100
@@ -28490,7 +28490,7 @@ static inline built_in_function
 complex_multiply_builtin_code (machine_mode mode)
 {
   gcc_assert (IN_RANGE (mode, MIN_MODE_COMPLEX_FLOAT, MAX_MODE_COMPLEX_FLOAT));
-  int func = BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT;
+  int func = BUILT_IN_COMPLEX_MUL_MIN + (mode - MIN_MODE_COMPLEX_FLOAT);
   return (built_in_function) func;
 }
 
@@ -28501,7 +28501,7 @@ static inline built_in_function
 complex_divide_builtin_code (machine_mode mode)
 {
   gcc_assert (IN_RANGE (mode, MIN_MODE_COMPLEX_FLOAT, MAX_MODE_COMPLEX_FLOAT));
-  int func = BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT;
+  int func = BUILT_IN_COMPLEX_DIV_MIN + (mode - MIN_MODE_COMPLEX_FLOAT);
   return (built_in_function) func;
 }
 

        Jakub

Reply via email to