From 5f8a6e1bdd8cec21724c7f368d373075d99e8a02 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 13 Sep 2016 21:53:08 +0300 Subject: [PATCH] Eliminate 'class defines member variable with name also defined in parent' cppcheck warning * tests/test_cpp.cc (F::nFreed, F::nAllocated): Add 'F' suffix to field name (to avoid hiding the similar one in the parent class). --- tests/test_cpp.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc index ed98fb73..d9ebd28d 100644 --- a/tests/test_cpp.cc +++ b/tests/test_cpp.cc @@ -170,19 +170,25 @@ class F: public E {public: member with clean-up. */ F() { - nAllocated++;} + nAllocatedF++; + } + ~F() { - nFreed++;} + nFreedF++; + } + static void Test() { - my_assert( nFreed >= .8 * nAllocated ); - my_assert( 2 * nFreed == E::nFreed );} + my_assert(nFreedF >= .8 * nAllocatedF); + my_assert(2 * nFreedF == nFreed); + } E e; - static int nFreed; - static int nAllocated;}; + static int nFreedF; + static int nAllocatedF; +}; -int F::nFreed = 0; -int F::nAllocated = 0; +int F::nFreedF = 0; +int F::nAllocatedF = 0; GC_word Disguise( void* p ) { -- 2.40.0