[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master d379d17 3/3: Label every '#endif'
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master d379d17 3/3: Label every '#endif' |
Date: |
Fri, 16 Apr 2021 20:18:00 -0400 (EDT) |
branch: master
commit d379d175992def214ff90047e489340ecf2c9c5b
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Label every '#endif'
A line of code will be read more often than written. A label need only
be written once to improve comprehensibility forever. This command:
git grep '#.*endif$' *.?pp
should find nothing.
* expression_template_0_test.cpp: Follow this rule.
* test_coding_rules.cpp: Enforce this rule.
---
expression_template_0_test.cpp | 4 ++--
test_coding_rules.cpp | 10 ++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/expression_template_0_test.cpp b/expression_template_0_test.cpp
index 815bcd2..005fb4b 100644
--- a/expression_template_0_test.cpp
+++ b/expression_template_0_test.cpp
@@ -48,11 +48,11 @@
# if defined LMI_CLANG
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-copy"
-# endif
+# endif // defined LMI_CLANG
# include <boost/numeric/ublas/vector.hpp>
# if defined LMI_CLANG
# pragma clang diagnostic pop
-# endif
+# endif // defined LMI_CLANG
#endif // defined USE_UBLAS
#include <algorithm>
diff --git a/test_coding_rules.cpp b/test_coding_rules.cpp
index 7bf150b..e97f03c 100644
--- a/test_coding_rules.cpp
+++ b/test_coding_rules.cpp
@@ -618,6 +618,16 @@ void check_cxx(file const& f)
}
}
+ {
+ static boost::regex const r(R"(# *endif\n)");
+ if
+ ( boost::regex_search(f.data(), r)
+ )
+ {
+ complain(f, "contains unlabelled '#endif' directive.");
+ }
+ }
+
// Tests above: C or C++. Tests below: C++ only.
if(!f.is_of_phylum(e_cxx))
{