public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Fix one range-loop-construct warning of avlprop
@ 2023-10-30 18:33 Jeff Law
  0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2023-10-30 18:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f8a45749fcce7d4fbbadc6b3350618510851fc3b

commit f8a45749fcce7d4fbbadc6b3350618510851fc3b
Author: Pan Li <pan2.li@intel.com>
Date:   Sat Oct 28 22:48:58 2023 +0800

    RISC-V: Fix one range-loop-construct warning of avlprop
    
    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>
    (cherry picked from commit b8b63e87669ef835e367f7b8ad437c6d1a6791f1)

Diff:
---
 gcc/config/riscv/riscv-avlprop.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/riscv/riscv-avlprop.cc b/gcc/config/riscv/riscv-avlprop.cc
index 2c79ec818067..c59eb7f6fa32 100644
--- a/gcc/config/riscv/riscv-avlprop.cc
+++ b/gcc/config/riscv/riscv-avlprop.cc
@@ -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));

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-30 18:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-30 18:33 [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Fix one range-loop-construct warning of avlprop Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).