]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Fix one range-loop-construct warning of avlprop
authorPan Li <pan2.li@intel.com>
Sat, 28 Oct 2023 14:48:58 +0000 (22:48 +0800)
committerPan Li <pan2.li@intel.com>
Sun, 29 Oct 2023 00:40:11 +0000 (08:40 +0800)
This patch would like to fix one warning of avlprop as below.

../../gcc/config/riscv/riscv-avlprop.cc: In member function 'virtual
unsigned int pass_avlprop::execute(function*)':
../../gcc/config/riscv/riscv-avlprop.cc:346:23: error: loop variable
'candidate' creates a copy from type 'const std::pair<avlprop_type,
rtl_ssa::insn_info*>' [-Werror=range-loop-construct]
  346 |       for (const auto candidate : m_candidates)
      |                       ^~~~~~~~~
../../gcc/config/riscv/riscv-avlprop.cc:346:23: note: use reference type
to prevent copying
  346 |       for (const auto candidate : m_candidates)
      |                       ^~~~~~~~~
      |                       &

gcc/ChangeLog:

* config/riscv/riscv-avlprop.cc (pass_avlprop::execute): Use
reference type to prevent copying.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/config/riscv/riscv-avlprop.cc

index 2c79ec818067c322cad4416bf985208e9f26c089..c59eb7f6fa324b403589dc9db0706af9cf451d0a 100644 (file)
@@ -343,7 +343,7 @@ pass_avlprop::execute (function *fn)
     {
       fprintf (dump_file, "\nNumber of potential AVL propagations: %d\n",
               m_candidates.length ());
-      for (const auto candidate : m_candidates)
+      for (const auto &candidate : m_candidates)
        {
          fprintf (dump_file, "\nAVL propagation type: %s\n",
                   avlprop_type_to_str (candidate.first));