https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92472
Bug ID: 92472
Summary: enhancement: 5 * constify some parameters
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: dcb314 at hotmail dot com
Target Milestone: ---
1.
For this message from static analyser cppcheck:
trunk/gcc/alloc-pool.h:63:39: style: Parameter 'total' can be declared with
const [constParameter]
This patch seems to fix the problem.
Index: gcc/alloc-pool.h
===================================================================
--- gcc/alloc-pool.h (revision 278050)
+++ gcc/alloc-pool.h (working copy)
@@ -60,7 +60,7 @@
/* Dump usage coupled to LOC location, where TOTAL is sum of all rows. */
inline void
- dump (mem_location *loc, mem_usage &total) const
+ dump (mem_location *loc, const mem_usage &total) const
{
char *location_string = loc->to_string ();
2.
Message:
trunk/gcc/bitmap.h:240:39: style: Parameter 'total' can be declared with const
[constParameter]
Patch:
Index: gcc/bitmap.h
===================================================================
--- gcc/bitmap.h (revision 278050)
+++ gcc/bitmap.h (working copy)
@@ -237,7 +237,7 @@
/* Dump usage coupled to LOC location, where TOTAL is sum of all rows. */
inline void
- dump (mem_location *loc, mem_usage &total) const
+ dump (mem_location *loc, const mem_usage &total) const
{
char *location_string = loc->to_string ();
3.
Message:
trunk/gcc/mem-stats.h:206:39: style: Parameter 'total' can be declared with
const [constParameter]
trunk/gcc/mem-stats.h:73:24: style: Parameter 'other' can be declared with
const [constParameter]
Patch:
Index: gcc/mem-stats.h
===================================================================
--- gcc/mem-stats.h (revision 278050)
+++ gcc/mem-stats.h (working copy)
@@ -70,7 +70,7 @@
/* Return true if the memory location is equal to OTHER. */
int
- equal (mem_location &other)
+ equal (const mem_location &other)
{
return m_filename == other.m_filename && m_function == other.m_function
&& m_line == other.m_line;
@@ -203,7 +203,7 @@
/* Dump usage coupled to LOC location, where TOTAL is sum of all rows. */
inline void
- dump (mem_location *loc, mem_usage &total) const
+ dump (mem_location *loc, const mem_usage &total) const
{
char *location_string = loc->to_string ();
4.
Message:
trunk/gcc/sese.h:48:23: style: Parameter 's' can be declared with const
[constParameter]
trunk/gcc/sese.h:56:22: style: Parameter 's' can be declared with const
[constParameter]
Patch:
Index: gcc/sese.h
===================================================================
--- gcc/sese.h (revision 278050)
+++ gcc/sese.h (working copy)
@@ -45,7 +45,7 @@
/* Get the entry of an sese S. */
static inline basic_block
-get_entry_bb (sese_l &s)
+get_entry_bb (const sese_l &s)
{
return s.entry->dest;
}
@@ -53,7 +53,7 @@
/* Get the exit of an sese S. */
static inline basic_block
-get_exit_bb (sese_l &s)
+get_exit_bb (const sese_l &s)
{
return s.exit->src;
}
5.
Message:
trunk/libstdc++-v3/include/parallel/multiway_merge.h:121:40: style: Parameter
'__bi2' can be declared with const [constParameter]
trunk/libstdc++-v3/include/parallel/multiway_merge.h:191:42: style: Parameter
'__bi2' can be declared with const [constParameter]
Patch:
Index: libstdc++-v3/include/parallel/multiway_merge.h
===================================================================
--- libstdc++-v3/include/parallel/multiway_merge.h (revision 278050)
+++ libstdc++-v3/include/parallel/multiway_merge.h (working copy)
@@ -118,7 +118,7 @@
* @return @c true if less. */
friend bool
operator<(_GuardedIterator<_RAIter, _Compare>& __bi1,
- _GuardedIterator<_RAIter, _Compare>& __bi2)
+ _GuardedIterator<_RAIter, const _Compare>& __bi2)
{
if (__bi1._M_current == __bi1._M_end) // __bi1 is sup
return __bi2._M_current == __bi2._M_end; // __bi2 is not sup
@@ -188,7 +188,7 @@
* @return @c true if less. */
friend bool
operator<(_UnguardedIterator<_RAIter, _Compare>& __bi1,
- _UnguardedIterator<_RAIter, _Compare>& __bi2)
+ _UnguardedIterator<_RAIter, const _Compare>& __bi2)
{
// Normal compare.
return (__bi1.__comp)(*__bi1, *__bi2);
All patches seemed to bootstrap ok.