From 9ca2672cabcd40e71732d920af268ab439d6b59f Mon Sep 17 00:00:00 2001 From: Yu-hsin Wang Date: Wed, 27 Sep 2023 12:48:26 +0800 Subject: [PATCH] misc: fix g++13 overloaded-virtual warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are two overloaded-virtual issues reported by g++13. 1. Copy assignment and move assignment overload is hidden in the derived class [ CXX] src/mem/cache/replacement_policies/weighted_lru_rp.cc -> ALL/mem/cache/replacement_policies/weighted_lru_rp.o In file included from src/mem/cache/base.hh:61, from src/mem/cache/base.cc:46: src/mem/cache/cache_blk.hh:172:5: error: ‘virtual gem5::CacheBlk& gem5::CacheBlk::operator=(gem5::CacheBlk&&)’ was hidden [-Werror=overloaded-virtual=] 172 | operator=(CacheBlk&& other) | ^~~~~~~~ src/mem/cache/cache_blk.hh:518:19: note: by ‘gem5::TempCacheBlk& gem5::TempCacheBlk::operator=(const gem5::TempCacheBlk&)’ 518 | TempCacheBlk& operator=(const TempCacheBlk&) = delete; | ^~~~~~~~ In this case, we can exiplict using parent operator= to keep the function overload. 2. Intended overload hidden in SystemC is reported as error. In file included from src/systemc/ext/tlm_utils/simple_initiator_socket.h:24, from src/systemc/tlm_bridge/gem5_to_tlm.hh:72, from build/ALL/python/_m5/param_Gem5ToTlmBridge256.cc:17: src/systemc/ext/tlm_utils/../tlm_core/2/sockets/initiator_socket.hh: In instantiation of ‘class tlm::tlm_base_initiator_socket<256, tlm::tlm_fw_transport_if<>, tlm::tlm_bw_transport_if<>, 1, sc_core::SC_ONE_OR_MORE_BOUND>’: src/systemc/ext/tlm_utils/../tlm_core/2/sockets/initiator_socket.hh:185:7: required from ‘class tlm::tlm_initiator_socket<256, tlm::tlm_base_protocol_types, 1, sc_core::SC_ONE_OR_MORE_BOUND>’ src/systemc/ext/tlm_utils/simple_initiator_socket.h:37:7: required from ‘class tlm_utils::simple_initiator_socket_b, 256, tlm::tlm_base_protocol_types, sc_core::SC_ONE_OR_MORE_BOUND>’ src/systemc/ext/tlm_utils/simple_initiator_socket.h:156:7: required from ‘class tlm_utils::simple_initiator_socket, 256, tlm::tlm_base_protocol_types>’ src/systemc/tlm_bridge/gem5_to_tlm.hh:147:46: required from ‘class sc_gem5::Gem5ToTlmBridge<256>’ /usr/include/c++/13/type_traits:1411:38: required from ‘struct std::is_base_of >’ ext/pybind11/include/pybind11/detail/../detail/common.h:880:59: required from ‘struct pybind11::class_, sc_gem5::Gem5ToTlmBridgeBase, std::unique_ptr, pybind11::nodelete> >::is_valid_class_option’ ext/pybind11/include/pybind11/detail/../detail/common.h:719:35: required by substitution of ‘template using pybind11::detail::all_of = pybind11::detail::bool_constant<(Ts::value && ...)> [with Ts = {pybind11::class_, sc_gem5::Gem5ToTlmBridgeBase, std::unique_ptr, pybind11::nodelete> >::is_valid_class_option, pybind11::class_, sc_gem5::Gem5ToTlmBridgeBase, std::unique_ptr, pybind11::nodelete> >::is_valid_class_option, pybind11::nodelete> >}]’ ext/pybind11/include/pybind11/pybind11.h:1506:70: required from ‘class pybind11::class_, sc_gem5::Gem5ToTlmBridgeBase, std::unique_ptr, pybind11::nodelete> >’ build/ALL/python/_m5/param_Gem5ToTlmBridge256.cc:34:179: required from here src/systemc/ext/tlm_utils/../core/sc_port.hh:125:18: error: ‘void sc_core::sc_port_b::bind(sc_core::sc_port_b&) [with IF = tlm::tlm_fw_transport_if<>]’ was hidden [-Werror=overloaded-virtual=] 125 | virtual void bind(sc_port_b &p) { sc_port_base::bind(p); } | ^~~~ In file included from src/systemc/ext/tlm_utils/simple_initiator_socket.h:27: src/systemc/ext/tlm_utils/../tlm_core/2/sockets/initiator_socket.hh:133:18: note: by ‘tlm::tlm_base_initiator_socket<256, tlm::tlm_fw_transport_if<>, tlm::tlm_bw_transport_if<>, 1, sc_core::SC_ONE_OR_MORE_BOUND>::bind’ 133 | virtual void bind(bw_interface_type &ifs) { (get_base_export())(ifs); } | ^~~~ src/systemc/ext/tlm_utils/../core/sc_port.hh:124:18: error: ‘void sc_core::sc_port_b::bind(IF&) [with IF = tlm::tlm_fw_transport_if<>]’ was hidden [-Werror=overloaded-virtual=] 124 | virtual void bind(IF &i) { sc_port_base::bind(i); } | ^~~~ src/systemc/ext/tlm_utils/../tlm_core/2/sockets/initiator_socket.hh:133:18: note: by ‘tlm::tlm_base_initiator_socket<256, tlm::tlm_fw_transport_if<>, tlm::tlm_bw_transport_if<>, 1, sc_core::SC_ONE_OR_MORE_BOUND>::bind’ 133 | virtual void bind(bw_interface_type &ifs) { (get_base_export())(ifs); } | ^~~~ From the code comment, it's intended in SystemC header. // The overloaded virtual is intended in SystemC, so we'll disable the warning. // Please check section 9.3 of SystemC 2.3.1 release note for more details. The issue is we should move the skip to the base class. Change-Id: I6683919e594ffe1fb3b87ccca1602bffdb788e7d --- src/mem/cache/cache_blk.hh | 1 + src/mem/cache/tags/fa_lru.hh | 1 + src/mem/cache/tags/sector_blk.hh | 1 + src/systemc/ext/core/sc_port.hh | 5 +++++ src/systemc/ext/tlm_core/2/sockets/initiator_socket.hh | 5 ----- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mem/cache/cache_blk.hh b/src/mem/cache/cache_blk.hh index 775efbe673..e476ab639d 100644 --- a/src/mem/cache/cache_blk.hh +++ b/src/mem/cache/cache_blk.hh @@ -515,6 +515,7 @@ class TempCacheBlk final : public CacheBlk data = new uint8_t[size]; } TempCacheBlk(const TempCacheBlk&) = delete; + using CacheBlk::operator=; TempCacheBlk& operator=(const TempCacheBlk&) = delete; ~TempCacheBlk() { delete [] data; }; diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh index cd07817007..dba89f809d 100644 --- a/src/mem/cache/tags/fa_lru.hh +++ b/src/mem/cache/tags/fa_lru.hh @@ -85,6 +85,7 @@ class FALRUBlk : public CacheBlk { public: FALRUBlk() : CacheBlk(), prev(nullptr), next(nullptr), inCachesMask(0) {} + using CacheBlk::operator=; /** The previous block in LRU order. */ FALRUBlk *prev; diff --git a/src/mem/cache/tags/sector_blk.hh b/src/mem/cache/tags/sector_blk.hh index dae8741e39..fbfea64d93 100644 --- a/src/mem/cache/tags/sector_blk.hh +++ b/src/mem/cache/tags/sector_blk.hh @@ -64,6 +64,7 @@ class SectorSubBlk : public CacheBlk public: SectorSubBlk() : CacheBlk(), _sectorBlk(nullptr), _sectorOffset(0) {} SectorSubBlk(const SectorSubBlk&) = delete; + using CacheBlk::operator=; SectorSubBlk& operator=(const SectorSubBlk&) = delete; SectorSubBlk(SectorSubBlk&&) = delete; /** diff --git a/src/systemc/ext/core/sc_port.hh b/src/systemc/ext/core/sc_port.hh index 796950e29b..bd57553559 100644 --- a/src/systemc/ext/core/sc_port.hh +++ b/src/systemc/ext/core/sc_port.hh @@ -114,6 +114,10 @@ class sc_port_base : public sc_object virtual sc_port_policy _portPolicy() const = 0; }; +// The overloaded virtual is intended in SystemC, so we'll disable the warning. +// Please check section 9.3 of SystemC 2.3.1 release note for more details. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Woverloaded-virtual" template class sc_port_b : public sc_port_base { @@ -244,6 +248,7 @@ class sc_port_b : public sc_port_base sc_port_b(const sc_port_b &) {} sc_port_b &operator = (const sc_port_b &) { return *this; } }; +#pragma GCC diagnostic pop template class sc_port : public sc_port_b diff --git a/src/systemc/ext/tlm_core/2/sockets/initiator_socket.hh b/src/systemc/ext/tlm_core/2/sockets/initiator_socket.hh index 4f67b59237..71fbf1b900 100644 --- a/src/systemc/ext/tlm_core/2/sockets/initiator_socket.hh +++ b/src/systemc/ext/tlm_core/2/sockets/initiator_socket.hh @@ -51,10 +51,6 @@ template class tlm_base_target_socket; -// The overloaded virtual is intended in SystemC, so we'll disable the warning. -// Please check section 9.3 of SystemC 2.3.1 release note for more details. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Woverloaded-virtual" template , typename BW_IF=tlm_bw_transport_if<>, int N=1, sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> @@ -174,7 +170,6 @@ class tlm_base_initiator_socket : protected: export_type m_export; }; -#pragma GCC diagnostic pop // // Convenience socket classes