lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] Enabling '-Wshadow' [Was: New clang errors fixes]


From: Greg Chicares
Subject: [lmi] Enabling '-Wshadow' [Was: New clang errors fixes]
Date: Wed, 27 Sep 2017 23:48:09 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 2017-09-27 12:41, Vadim Zeitlin wrote:
> On Wed, 27 Sep 2017 11:13:29 +0000 Greg Chicares <address@hidden> wrote:
> 
> GC> Can you readily say which occurrence(s) clang objects to?
> 
>  I had initially just skipped the error details because there were several
> screens of them, but looking at them closer now I see that there actually
> seems to be only one real problem: the use of auto_ptr<> as scoped_ptr ctor
> argument in boost/scoped_ptr.hpp which is included from
> boost/regex/v4/regex_workaround.hpp from boost/regex/v4/regex.hpp from
> boost/regex.hpp itself.

Because we're discussing warnings, I took another look at '-Wshadow',
and found we can enable it if we make just a few changes. One trigger
for this warning is 'boost/regex.hpp', so I decided to handle the
gcc and clang problems through a new 'boost_regex.hpp' wrapper.

Another source of gcc '-Wshadow' warnings can be removed by updating
  include/xmlwrapp/node.h, line 165 here:
  https://github.com/vslavik/xmlwrapp/blob/master/include/xmlwrapp/node.h
in this vein:

-      explicit text (const char *text) : t(text) {}
+      explicit text (const char *arg) : t(arg) {}

using any name except 'text' for the argument.

Then we'll just have four '-Wshadow' errors in lmi itself. I've already
tested a fix for the one in 'accountvalue.cpp'. Could I ask you to
propose changes for the three below, because you're more familiar with
these files?

/opt/lmi/src/lmi/wx_table_generator.cpp: In constructor 
‘wx_table_generator::wx_table_generator(wxDC&, int, int)’:
/opt/lmi/src/lmi/wx_table_generator.cpp:50:5: error: declaration of ‘dc_’ 
shadows a member of ‘wx_table_generator’ [-Werror=shadow]
     )
     ^
In file included from /opt/lmi/src/lmi/wx_table_generator.cpp:24:0:
/opt/lmi/src/lmi/wx_table_generator.hpp:124:11: note: shadowed declaration is 
here
     wxDC& dc_;
           ^~~

/opt/lmi/src/lmi/wx_test_validate_output.cpp: In constructor 
‘{anonymous}::init_test_census(const string&, const 
string&)::change_name_in_cell_dialog::change_name_in_cell_dialog(const 
string&)’:
/opt/lmi/src/lmi/wx_test_validate_output.cpp:161:13: error: declaration of 
‘insured_name’ shadows a member of ‘{anonymous}::init_test_census(const 
string&, const string&)::change_name_in_cell_dialog’ [-Werror=shadow]
             :insured_name(insured_name)
             ^
/opt/lmi/src/lmi/wx_test_validate_output.cpp:184:28: note: shadowed declaration 
is here
         std::string const& insured_name;
                            ^~~~~~~~~~~~

/opt/lmi/src/lmi/main_wx_test.cpp: In constructor 
‘{anonymous}::application_test::test_descriptor::test_descriptor(wx_base_test_case*)’:
/opt/lmi/src/lmi/main_wx_test.cpp:204:13: error: declaration of ‘test’ shadows 
a member of ‘{anonymous}::application_test::test_descriptor’ [-Werror=shadow]
             :test(test)
             ^
/opt/lmi/src/lmi/main_wx_test.cpp:221:28: note: shadowed declaration is here
         wx_base_test_case* test;
                            ^~~~

> BTW, please notice that my patch only fixed the warnings that appear
> during the compilation of lmi itself, i.e. those in the headers, because I
> assumed Boost source files themselves could be just compiled with
> -Wno-deprecated-declarations.

It's already suppressed (too generally) in 'workhorse.make':

else ifneq (,$(filter $(gcc_version), 6.3.0))
  # See:
  #   http://lists.nongnu.org/archive/html/lmi/2015-12/msg00028.html
  #   http://lists.nongnu.org/archive/html/lmi/2015-12/msg00040.html
  # XMLWRAPP !! '-Wno-deprecated-declarations' needed for auto_ptr
  gcc_version_specific_warnings := \
    -Wno-conversion \
    -Wno-deprecated-declarations \
    -Wno-parentheses \
    -Wno-unused-local-typedefs \
    -Wno-unused-variable \

However, maybe I can enable this warning for gcc: my as-yet-uncommitted
'boost_regex.hpp' change uses a pragma to turn it off, and I'll add

$(boost_regex_objects): gcc_common_extra_warnings += \
  -Wno-deprecated-declarations \
  -Wno-shadow \

to cover the library objects themselves.

As for the comment above:
  # XMLWRAPP !! '-Wno-deprecated-declarations' needed for auto_ptr
wasn't auto_ptr already removed from xmlwrapp, so that I should
just update to the latest version (hopefully after you consider
the "text (const char *text) : t(text)" change above)?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]