lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master f6977a5 2/2: Enable '-Wshadow', addressing al


From: Greg Chicares
Subject: [lmi-commits] [lmi] master f6977a5 2/2: Enable '-Wshadow', addressing all the remaining diagnostics it produced
Date: Mon, 2 Oct 2017 10:34:08 -0400 (EDT)

branch: master
commit f6977a5f22aa0a07b2122d3d408f10f6e57c650a
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Enable '-Wshadow', addressing all the remaining diagnostics it produced
---
 accountvalue.cpp            |  6 +++---
 calendar_date_test.cpp      | 20 ++++++++++----------
 main_wx_test.cpp            |  4 ++--
 test_coding_rules.cpp       |  2 ++
 tn_range_test.cpp           |  2 +-
 value_cast_test.cpp         |  2 ++
 workhorse.make              |  8 ++++++--
 wx_test_validate_output.cpp |  6 +++---
 8 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/accountvalue.cpp b/accountvalue.cpp
index 779830d..50d0ac3 100644
--- a/accountvalue.cpp
+++ b/accountvalue.cpp
@@ -881,14 +881,14 @@ void AccountValue::TxTakeWD()
     //   max loan: cannot become overloaned until end of policy year.
     // However, lmi provides a variety of implementations instead of
     // only one.
-    double MaxWD =
+    double max_wd =
           AVUnloaned
         + (AVRegLn  + AVPrfLn)
         - (RegLnBal + PrfLnBal)
         - mlydedtonextmodalpmtdate;
-    if(MaxWD < wd)
+    if(max_wd < wd)
         {
-        wd = MaxWD;
+        wd = max_wd;
         }
 
     AVUnloaned -= wd;
diff --git a/calendar_date_test.cpp b/calendar_date_test.cpp
index 7ab1454..729502d 100644
--- a/calendar_date_test.cpp
+++ b/calendar_date_test.cpp
@@ -1052,20 +1052,20 @@ namespace
 
     void mete()
     {
-        calendar_date x;
-        calendar_date y(1899, 12, 31);
-        x = y;
-        x++;
-        std::string s = x.str();
-        x = add_years_and_months(x, 1, 1, true);
-        attained_age(y, x, oe_age_last_birthday);
-        y = minimum_birthdate(45, x, oe_age_last_birthday);
+        calendar_date t;
+        calendar_date u(1899, 12, 31);
+        t = u;
+        t++;
+        std::string s = t.str();
+        t = add_years_and_months(t, 1, 1, true);
+        attained_age(u, t, oe_age_last_birthday);
+        u = minimum_birthdate(45, t, oe_age_last_birthday);
     }
 
     void mete_construct()
     {
-        calendar_date x;
-        calendar_date y(1899, 12, 31);
+        calendar_date t;
+        calendar_date u(1899, 12, 31);
     }
 
     void mete_assign()
diff --git a/main_wx_test.cpp b/main_wx_test.cpp
index 6691b4d..f96aef8 100644
--- a/main_wx_test.cpp
+++ b/main_wx_test.cpp
@@ -200,8 +200,8 @@ class application_test final
     struct test_descriptor
     {
         // The pointer must be non-NULL but we don't take ownership of it.
-        test_descriptor(wx_base_test_case* test)
-            :test(test)
+        test_descriptor(wx_base_test_case* t)
+            :test(t)
             ,run(run_default)
         {
         }
diff --git a/test_coding_rules.cpp b/test_coding_rules.cpp
index 7b2f1b3..b7f5c36 100644
--- a/test_coding_rules.cpp
+++ b/test_coding_rules.cpp
@@ -484,9 +484,11 @@ void check_copyright(file const& f)
     LMI_ASSERT(nullptr != t1);
     int const year = 1900 + t1->tm_year;
 
+    { // Scope to avoid unwanted '-Wshadow' diagnostic.
     std::ostringstream oss;
     oss << R"(Copyright \(C\)[^\n]*)" << year;
     require(f, oss.str(), "lacks current copyright.");
+    }
 
     if(f.is_of_phylum(e_html) && !f.phyloanalyze("^COPYING"))
         {
diff --git a/tn_range_test.cpp b/tn_range_test.cpp
index b5b45c4..ecb2e6c 100644
--- a/tn_range_test.cpp
+++ b/tn_range_test.cpp
@@ -595,7 +595,7 @@ void tn_range_test::test_absurd_limits()
         );
 
     BOOST_TEST_THROW
-        (r_absurd a;
+        (r_absurd b;
         ,std::runtime_error
         ,"Lower bound 1 exceeds upper bound 0 ."
         );
diff --git a/value_cast_test.cpp b/value_cast_test.cpp
index e497ce4..84adbf0 100644
--- a/value_cast_test.cpp
+++ b/value_cast_test.cpp
@@ -240,12 +240,14 @@ int extra_tests0()
         ,strip( ".00000000000000000000123300000000")
         );
 
+    {
     char const* nptr = "0.";
     char rendptr[100] = {'\0'};
     char* endptr = rendptr;
     std::strtod(nptr, &endptr);
     BOOST_TEST_EQUAL('\0', *endptr);
     BOOST_TEST_UNEQUAL(nptr, endptr);
+    }
 
     BOOST_TEST_EQUAL("0", strip("00."  ));
     BOOST_TEST_EQUAL("0", strip( "0."  ));
diff --git a/workhorse.make b/workhorse.make
index 0a35376..23456b5 100644
--- a/workhorse.make
+++ b/workhorse.make
@@ -420,6 +420,7 @@ gcc_common_warnings := \
   -Wpacked \
   -Wpointer-arith \
   -Wredundant-decls \
+  -Wshadow \
   -Wsign-compare \
   -Wundef \
   -Wunreachable-code \
@@ -465,6 +466,10 @@ endif
 operations_posix_windows.o: gcc_common_extra_warnings += -Wno-unused-parameter
 operations_posix_windows.o: gcc_common_extra_warnings += 
-Wno-maybe-uninitialized
 
+# The boost regex library is incompatible with '-Wshadow'.
+
+$(boost_regex_objects): gcc_common_extra_warnings += -Wno-shadow
+
 # The boost regex library improperly defines "NOMINMAX":
 #   http://lists.boost.org/Archives/boost/2006/03/102189.php
 # at least in version 1.33.1, and there seems to be no easy workaround
@@ -484,9 +489,8 @@ endif
 # any workarounds for gcc-3.3+ . However, it gives a number of
 # warnings with wx-2.5.4 (that have been fixed in a later version).
 
-# Too many warnings for various boost libraries:
+# Too many warnings for wx and various boost libraries:
 #  -Wold-style-cast \
-#  -Wshadow \
 
 C_WARNINGS = \
   $(gcc_c_warnings) \
diff --git a/wx_test_validate_output.cpp b/wx_test_validate_output.cpp
index 7507089..6efc64a 100644
--- a/wx_test_validate_output.cpp
+++ b/wx_test_validate_output.cpp
@@ -158,7 +158,7 @@ void init_test_census
         :public wxExpectModalBase<MvcController>
     {
         change_name_in_cell_dialog(std::string const& insured_name)
-            :insured_name(insured_name)
+            :insured_name_(insured_name)
             {
             }
 
@@ -170,7 +170,7 @@ void init_test_census
             wx_test_focus_controller_child(*dialog, "InsuredName");
 
             wxUIActionSimulator ui;
-            ui.Text(insured_name.c_str());
+            ui.Text(insured_name_.c_str());
             wxYield();
 
             return wxID_OK;
@@ -181,7 +181,7 @@ void init_test_census
             return "census cell dialog";
             }
 
-        std::string const& insured_name;
+        std::string const& insured_name_;
     };
 
     ui.Char('e', wxMOD_CONTROL); // "Census|Edit cell"



reply via email to

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