public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v1] RISC-V: Fix one range-loop-construct warning of avlprop
@ 2023-10-28 14:51 pan2.li
  2023-10-28 15:00 ` Jeff Law
  0 siblings, 1 reply; 3+ messages in thread
From: pan2.li @ 2023-10-28 14:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: juzhe.zhong, pan2.li, yanzhang.wang, kito.cheng

From: Pan Li <pan2.li@intel.com>

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 | 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 2c79ec81806..c59eb7f6fa3 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));
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] RISC-V: Fix one range-loop-construct warning of avlprop
  2023-10-28 14:51 [PATCH v1] RISC-V: Fix one range-loop-construct warning of avlprop pan2.li
@ 2023-10-28 15:00 ` Jeff Law
  2023-10-29  0:41   ` Li, Pan2
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2023-10-28 15:00 UTC (permalink / raw)
  To: pan2.li, gcc-patches; +Cc: juzhe.zhong, yanzhang.wang, kito.cheng



On 10/28/23 08:51, pan2.li@intel.com wrote:
> From: Pan Li <pan2.li@intel.com>
> 
> 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.
OK
jeff
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH v1] RISC-V: Fix one range-loop-construct warning of avlprop
  2023-10-28 15:00 ` Jeff Law
@ 2023-10-29  0:41   ` Li, Pan2
  0 siblings, 0 replies; 3+ messages in thread
From: Li, Pan2 @ 2023-10-29  0:41 UTC (permalink / raw)
  To: Jeff Law, gcc-patches; +Cc: juzhe.zhong, Wang, Yanzhang, kito.cheng

Committed, thanks Jeff.

Pan

-----Original Message-----
From: Jeff Law <jeffreyalaw@gmail.com> 
Sent: Saturday, October 28, 2023 11:00 PM
To: Li, Pan2 <pan2.li@intel.com>; gcc-patches@gcc.gnu.org
Cc: juzhe.zhong@rivai.ai; Wang, Yanzhang <yanzhang.wang@intel.com>; kito.cheng@gmail.com
Subject: Re: [PATCH v1] RISC-V: Fix one range-loop-construct warning of avlprop



On 10/28/23 08:51, pan2.li@intel.com wrote:
> From: Pan Li <pan2.li@intel.com>
> 
> 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.
OK
jeff
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-29  0:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-28 14:51 [PATCH v1] RISC-V: Fix one range-loop-construct warning of avlprop pan2.li
2023-10-28 15:00 ` Jeff Law
2023-10-29  0:41   ` Li, Pan2

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).