cobol: Minor changes to quiet cppcheck warnings. [PR119324]
gcc/cobol/ChangeLog:
PR cobol/119324
* cbldiag.h (location_dump): Inline suppression of knownConditionTrueFalse.
* genapi.cc (parser_statement_begin): Combine two if() statements.
* genutil.cc (get_binary_value): File-level suppression of duplicateBreak.
* symbols.cc (symbol_elem_cmp): File-level suppression of duplicateBreak.
diff --git a/gcc/cobol/cbldiag.h b/gcc/cobol/cbldiag.h
index 39f1369..dd16190 100644
--- a/gcc/cobol/cbldiag.h
+++ b/gcc/cobol/cbldiag.h
@@ -122,7 +122,7 @@
location_dump( const char func[], int line, const char tag[], const LOC& loc) {
extern int yy_flex_debug; // cppcheck-suppress shadowVariable
if( yy_flex_debug ) {
- const char *detail = gcobol_getenv("update_location");
+ const char *detail = gcobol_getenv("update_location"); // cppcheck-suppress knownConditionTrueFalse
if( detail ) {
fprintf(stderr, "%s:%d: %s location (%d,%d) to (%d,%d)\n",
func, line, tag,
diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index 2034164..c9d2da4 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -1198,12 +1198,9 @@
if( exception_processing )
{
store_location_stuff(statement_name);
- }
-
- if( exception_processing )
- {
set_exception_environment(ecs, dcls);
}
+
sv_is_i_o = false;
}
diff --git a/gcc/cobol/genutil.cc b/gcc/cobol/genutil.cc
index 7895ea8..a5f69a0 100644
--- a/gcc/cobol/genutil.cc
+++ b/gcc/cobol/genutil.cc
@@ -27,6 +27,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
+// cppcheck-suppress-file duplicateBreak
+
#include "cobol-system.h"
#include "coretypes.h"
#include "tree.h"
@@ -1267,7 +1270,7 @@
cbl_field_type_str(field->type) );
cbl_internal_error("%s", err);
abort();
- // break; // break not needed after abort();
+ break;
}
}
diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc
index 7d6a955..f2cd1b5 100644
--- a/gcc/cobol/symbols.cc
+++ b/gcc/cobol/symbols.cc
@@ -28,6 +28,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+// cppcheck-suppress-file duplicateBreak
+
#include "config.h"
#include <fstream> // Before cobol-system because it uses poisoned functions
#include "cobol-system.h"
@@ -500,13 +502,13 @@
}
return strcasecmp(key.name, elem.name);
}
- // break; // This break not needed if all options do a return.
+ break;
case SymSpecial:
return special_pair_cmp(k->elem.special, e->elem.special)? 0 : 1;
- // break; // This break not needed after return.
+ break;
case SymAlphabet:
return strcasecmp(k->elem.alphabet.name, e->elem.alphabet.name);
- // break; // This break not needed after return.
+ break;
case SymFile:
// If the key is global, so must be the found element.
if( (cbl_file_of(k)->attr & global_e) == global_e &&
@@ -514,7 +516,7 @@
return 1;
}
return strcasecmp(k->elem.file.name, e->elem.file.name);
- // break; // This break not needed after return.
+ break;
}
assert(k->type == SymField);