lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 68095897 6/6: Use [[fallthrough]]


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 68095897 6/6: Use [[fallthrough]]
Date: Fri, 8 Jul 2022 16:59:16 -0400 (EDT)

branch: master
commit 680958973fc6355c74446a2f9d21d462eabc7ebb
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Use [[fallthrough]]
    
    A comment such as
      // fall through
    was enough to silence gcc, but not clang. This
      [[fallthrough]];
    is preferable because it's standard and works with any proper compiler:
    it's like a standard comment.
---
 accountvalue.cpp             | 24 ++++++++++++------------
 compiler_clang_warnings.make |  2 --
 duff_fmt.hpp                 |  6 +++---
 getopt.cpp                   | 12 ++++++------
 group_quote_pdf_gen_wx.cpp   | 23 ++++++++++++-----------
 ledger.cpp                   |  8 ++++----
 pdf_command_wx.cpp           |  6 +++---
 round_to.hpp                 |  2 +-
 solve.cpp                    | 12 ++++++------
 9 files changed, 47 insertions(+), 48 deletions(-)

diff --git a/accountvalue.cpp b/accountvalue.cpp
index 11a04609..f6f4aa03 100644
--- a/accountvalue.cpp
+++ b/accountvalue.cpp
@@ -472,9 +472,9 @@ void AccountValue::PerformSpecAmtStrategy()
             SA = base_specamt(0);
             }
             break;
-        case mce_sa_gsp:      // fall through
-        case mce_sa_corridor: // fall through
-        case mce_sa_salary:   // fall through
+        case mce_sa_gsp:      [[fallthrough]];
+        case mce_sa_corridor: [[fallthrough]];
+        case mce_sa_salary:   [[fallthrough]];
         default:
             {
             alarum()
@@ -536,8 +536,8 @@ void AccountValue::TxOptionChange()
             // An alternative is to lapse the policy.
             }
             break;
-        case mce_rop: // fall through
-        case mce_mdb: // fall through
+        case mce_rop: [[fallthrough]];
+        case mce_mdb: [[fallthrough]];
         default:
             {
             alarum() << "Case " << YearsDBOpt << " not found." << LMI_FLUSH;
@@ -648,9 +648,9 @@ void AccountValue::PerformPmtStrategy(currency* a_Pmt)
             *a_Pmt = stored_pmts[Year];
             }
             break;
-        case mce_pmt_gsp:      // fall through
-        case mce_pmt_corridor: // fall through
-        case mce_pmt_table:    // fall through
+        case mce_pmt_gsp:      [[fallthrough]];
+        case mce_pmt_corridor: [[fallthrough]];
+        case mce_pmt_table:    [[fallthrough]];
         default:
             {
             alarum()
@@ -759,8 +759,8 @@ void AccountValue::TxSetDeathBft()
             // Negative AV doesn't decrease death benefit.
             deathbft = std::max(ActualSpecAmt + std::max(C0, AV), corr);
             break;
-        case mce_rop: // fall through
-        case mce_mdb: // fall through
+        case mce_rop: [[fallthrough]];
+        case mce_mdb: [[fallthrough]];
         default:
             {
             alarum() << "Case " << YearsDBOpt << " not found." << LMI_FLUSH;
@@ -933,8 +933,8 @@ void AccountValue::TxTakeWD()
         case mce_option2:
             ;
             break;
-        case mce_rop: // fall through
-        case mce_mdb: // fall through
+        case mce_rop: [[fallthrough]];
+        case mce_mdb: [[fallthrough]];
         default:
             {
             alarum() << "Case " << YearsDBOpt << " not found." << LMI_FLUSH;
diff --git a/compiler_clang_warnings.make b/compiler_clang_warnings.make
index 3491b791..3ea918d5 100644
--- a/compiler_clang_warnings.make
+++ b/compiler_clang_warnings.make
@@ -66,7 +66,6 @@ clang_c_warnings := \
 ###  -Wfloat-conversion
 # -Wfloat-equal: too many false positives, e.g., 0.0 == X
 ###  -Wglobal-constructors
-###  -Wimplicit-fallthrough
 # -Wlogical-op-parentheses: && is multiplicative; || is additive
 # -Wmismatched-tags: stylistic freedom--not a defect
 ###  -Wmissing-noreturn
@@ -99,7 +98,6 @@ clang_cxx_warnings := \
   -Wno-float-conversion \
   -Wno-float-equal \
   -Wno-global-constructors \
-  -Wno-implicit-fallthrough \
   -Wno-logical-op-parentheses \
   -Wno-mismatched-tags \
   -Wno-missing-noreturn \
diff --git a/duff_fmt.hpp b/duff_fmt.hpp
index 83f3c17f..eb4789ac 100644
--- a/duff_fmt.hpp
+++ b/duff_fmt.hpp
@@ -65,9 +65,9 @@ inline std::string duff_fmt(double value, int decimals)
                 do
                     {
                     if('.' == *p) break;
-                    *q++ = ',';  // fall through
-        case 0:     *q++ = *p++; // fall through
-        case 2:     *q++ = *p++; // fall through
+                    *q++ = ',';  [[fallthrough]];
+        case 0:     *q++ = *p++; [[fallthrough]];
+        case 2:     *q++ = *p++; [[fallthrough]];
         case 1:     *q++ = *p++;
                     }
                 while(*p);
diff --git a/getopt.cpp b/getopt.cpp
index bfb827a5..83ee66bc 100644
--- a/getopt.cpp
+++ b/getopt.cpp
@@ -599,11 +599,11 @@ GetOpt::operator()()
                 return '?';
 
               case LIST_ARG:
-                list_option = pfound; // fall through
+                list_option = pfound; [[fallthrough]];
 
-              case REQD_ARG: // fall through
-              case OPT_ARG:  // fall through
-              case ALT_ARG:  // fall through
+              case REQD_ARG: [[fallthrough]];
+              case OPT_ARG:  [[fallthrough]];
+              case ALT_ARG:  [[fallthrough]];
               default:
                 optarg = nameend + 1;
                 break;
@@ -637,8 +637,8 @@ GetOpt::operator()()
                   }
                 break;
 
-              case NO_ARG:  // fall through
-              case OPT_ARG: // fall through
+              case NO_ARG:  [[fallthrough]];
+              case OPT_ARG: [[fallthrough]];
               default:
                 optarg = nullptr;
                 break;
diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index e13e8fd7..52b53c79 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -669,11 +669,11 @@ void group_quote_pdf_generator_wx::save(std::string 
const& output_filename)
             case e_col_supplemental_face_amount:
             case e_col_total_face_amount:
                 if(!has_suppl_amount) {visibility = oe_hidden;}
-                // Fall through
-            case e_col_number:
-            case e_col_name:
-            case e_col_age:
-            case e_col_dob:
+                [[fallthrough]];
+            case e_col_number: [[fallthrough]];
+            case e_col_name:   [[fallthrough]];
+            case e_col_age:    [[fallthrough]];
+            case e_col_dob:    [[fallthrough]];
             case e_col_basic_face_amount:
                 // Labels of these columns are simple literals.
                 header = cd.header_;
@@ -681,7 +681,7 @@ void group_quote_pdf_generator_wx::save(std::string const& 
output_filename)
             case e_col_additional_premium:
             case e_col_total_premium:
                 if(!has_addl_premium) {visibility = oe_hidden;}
-                // Fall through
+                [[fallthrough]];
             case e_col_basic_premium:
                 {
                 // Labels of these columns are format strings as they need to
@@ -1151,11 +1151,12 @@ void 
group_quote_pdf_generator_wx::output_aggregate_values
                 // Do nothing: leave 'average_text' empty.
                 }
                 break;
-            case e_col_number: // fall through--should be unreachable
-            case e_col_name:   // fall through--should be unreachable
-            case e_col_age:    // fall through--should be unreachable
-            case e_col_dob:    // fall through--should be unreachable
-            case e_col_max:    // fall through--should be unreachable
+            // These cases should all be unreachable.
+            case e_col_number: [[fallthrough]];
+            case e_col_name:   [[fallthrough]];
+            case e_col_age:    [[fallthrough]];
+            case e_col_dob:    [[fallthrough]];
+            case e_col_max:    [[fallthrough]];
             default:
                 {
                 alarum() << "Case " << i << " not found." << LMI_FLUSH;
diff --git a/ledger.cpp b/ledger.cpp
index 834ab73a..300194d0 100644
--- a/ledger.cpp
+++ b/ledger.cpp
@@ -108,8 +108,8 @@ void Ledger::SetRunBases(int length)
             l_map_rep[mce_run_gen_mdpt_sep_full] = LedgerVariant(length);
             }
             break;
-        case mce_group_private_placement:      // Deliberately fall through.
-        case mce_individual_private_placement: // Deliberately fall through.
+        case mce_group_private_placement:      [[fallthrough]];
+        case mce_individual_private_placement: [[fallthrough]];
         case mce_finra:
             {
             l_map_rep[mce_run_gen_curr_sep_full] = LedgerVariant(length);
@@ -134,8 +134,8 @@ void Ledger::SetRunBases(int length)
             l_map_rep[mce_run_gen_guar_sep_half] = LedgerVariant(length);
             }
             break;
-        case mce_offshore_private_placement_obsolete: // fall through
-        case mce_ill_reg_private_placement_obsolete:  // fall through
+        case mce_offshore_private_placement_obsolete: [[fallthrough]];
+        case mce_ill_reg_private_placement_obsolete:  [[fallthrough]];
         case mce_variable_annuity_obsolete:
             {
             alarum() << "Unsupported ledger type '" << ledger_type_ << "'." << 
LMI_FLUSH;
diff --git a/pdf_command_wx.cpp b/pdf_command_wx.cpp
index 6524a646..b432fd00 100644
--- a/pdf_command_wx.cpp
+++ b/pdf_command_wx.cpp
@@ -3245,7 +3245,7 @@ void concrete_pdf_command(Ledger const& ledger, fs::path 
const& pdf_out_file)
         case mce_ill_reg:
             pdf_illustration_naic        (ledger, pdf_out_file).render_all();
             break;
-        case mce_prospectus_abeyed: // fall through
+        case mce_prospectus_abeyed: [[fallthrough]];
         case mce_finra:
             pdf_illustration_finra       (ledger, pdf_out_file).render_all();
             break;
@@ -3255,8 +3255,8 @@ void concrete_pdf_command(Ledger const& ledger, fs::path 
const& pdf_out_file)
         case mce_individual_private_placement:
             pdf_illustration_reg_d_indiv (ledger, pdf_out_file).render_all();
             break;
-        case mce_offshore_private_placement_obsolete: // fall through
-        case mce_ill_reg_private_placement_obsolete:  // fall through
+        case mce_offshore_private_placement_obsolete: [[fallthrough]];
+        case mce_ill_reg_private_placement_obsolete:  [[fallthrough]];
         case mce_variable_annuity_obsolete:
             alarum() << "Unsupported ledger type." << LMI_FLUSH;
         }
diff --git a/round_to.hpp b/round_to.hpp
index 5390acf7..a89b1bd3 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -424,7 +424,7 @@ round_to<RealType>::select_rounding_function(rounding_style 
const a_style) const
             {
             return detail::round_not;
             }
-        case r_indeterminate: // fall through--always invalid
+        case r_indeterminate: [[fallthrough]]; // always invalid
         default:
             {
             throw std::domain_error("Invalid rounding style.");
diff --git a/solve.cpp b/solve.cpp
index fb15ad7c..a9dd0197 100644
--- a/solve.cpp
+++ b/solve.cpp
@@ -118,8 +118,8 @@ currency SolveTest()
                     y = ConstThat->base_specamt(ThatSolveTgtYear - 1);
                     }
                     break;
-                case mce_rop: // fall through
-                case mce_mdb: // fall through
+                case mce_rop: [[fallthrough]];
+                case mce_mdb: [[fallthrough]];
                 default:
                     {
                     alarum()
@@ -137,8 +137,8 @@ currency SolveTest()
             y = round_to_cents.c(ThatSolveTargetValue);
             }
             break;
-        case mce_solve_for_target_naar: // Fall through.
-        case mce_solve_for_tax_basis:   // Fall through.
+        case mce_solve_for_target_naar: [[fallthrough]];
+        case mce_solve_for_tax_basis:   [[fallthrough]];
         case mce_solve_for_non_mec:
             {
             alarum() << "Not implemented.";
@@ -303,8 +303,8 @@ currency AccountValue::Solve()
             SolveFn    = SolveWD;
             }
             break;
-        case mce_solve_none:    // fall through
-        case mce_solve_er_prem: // fall through
+        case mce_solve_none:    [[fallthrough]];
+        case mce_solve_er_prem: [[fallthrough]];
         default:
             {
             alarum()



reply via email to

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