From b052a4d133cd3f5862a40a85a9eb863c6c2c4d7e Mon Sep 17 00:00:00 2001 From: Kareem Khazem Date: Mon, 26 Mar 2018 05:32:36 +0100 Subject: [PATCH] Fix warnings emitted by C++2a compiler This commit fixes #1972, in particular fixing these three classes of error that occurred over various files in the codebase: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../include/c++/7.3.1/ext/new_allocator.h:140:22: error: destructor called on non-final 'java_bytecode_parse_treet::methodt' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor] destroy(_Up* __p) { __p->~_Up(); } ^ cbmc/src/pointer-analysis/value_set_fivr.cpp:857:9: error: parentheses were disambiguated as redundant parentheses around declaration of variable named 'it' [-Werror,-Wvexing-parse] forall_objects(it, omt.read()) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cbmc/src/cpp/cpp_typecheck_resolve.cpp:591:34: error: unused variable 'next' [-Werror,-Wunused-variable] resolve_identifierst::iterator next; ^ These warnings are emitted when building with Clang 6.0 with the default flags. As of this commit, one warning remains, which can be suppressed by building with the flag -Wno-c++2a-compat until we have a proper fix. --- src/cpp/cpp_typecheck_resolve.cpp | 2 -- src/goto-instrument/cover_basic_blocks.h | 1 + src/goto-instrument/cover_instrument.h | 1 + src/java_bytecode/java_bytecode_parse_tree.h | 4 ++++ src/pointer-analysis/value_set_fi.cpp | 8 ++++---- src/pointer-analysis/value_set_fivr.cpp | 18 +++++++++--------- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/cpp/cpp_typecheck_resolve.cpp b/src/cpp/cpp_typecheck_resolve.cpp index 3be1b09d651..afc841da20b 100644 --- a/src/cpp/cpp_typecheck_resolve.cpp +++ b/src/cpp/cpp_typecheck_resolve.cpp @@ -588,8 +588,6 @@ void cpp_typecheck_resolvet::make_constructors( { resolve_identifierst new_identifiers; - resolve_identifierst::iterator next; - for(resolve_identifierst::iterator it=identifiers.begin(); it!=identifiers.end(); diff --git a/src/goto-instrument/cover_basic_blocks.h b/src/goto-instrument/cover_basic_blocks.h index 25d37d7df80..95ac68e4d23 100644 --- a/src/goto-instrument/cover_basic_blocks.h +++ b/src/goto-instrument/cover_basic_blocks.h @@ -21,6 +21,7 @@ class message_handlert; class cover_blocks_baset { public: + virtual ~cover_blocks_baset() = default; /// \param t a goto instruction /// \return the block number of the block /// the given goto instruction is part of diff --git a/src/goto-instrument/cover_instrument.h b/src/goto-instrument/cover_instrument.h index 465165ae29b..e6d501253de 100644 --- a/src/goto-instrument/cover_instrument.h +++ b/src/goto-instrument/cover_instrument.h @@ -25,6 +25,7 @@ class goal_filterst; class cover_instrumenter_baset { public: + virtual ~cover_instrumenter_baset() = default; cover_instrumenter_baset( const symbol_tablet &_symbol_table, const goal_filterst &_goal_filters, diff --git a/src/java_bytecode/java_bytecode_parse_tree.h b/src/java_bytecode/java_bytecode_parse_tree.h index 42a04f5200b..d29e714cb76 100644 --- a/src/java_bytecode/java_bytecode_parse_tree.h +++ b/src/java_bytecode/java_bytecode_parse_tree.h @@ -21,6 +21,7 @@ Author: Daniel Kroening, kroening@kroening.com class java_bytecode_parse_treet { public: + virtual ~java_bytecode_parse_treet() = default; class annotationt { public: @@ -157,11 +158,14 @@ class java_bytecode_parse_treet is_synchronized(false) { } + + virtual ~methodt() = default; }; class fieldt:public membert { public: + virtual ~fieldt() = default; virtual void output(std::ostream &out) const; bool is_enum; }; diff --git a/src/pointer-analysis/value_set_fi.cpp b/src/pointer-analysis/value_set_fi.cpp index 1dc9b756910..c126c5da760 100644 --- a/src/pointer-analysis/value_set_fi.cpp +++ b/src/pointer-analysis/value_set_fi.cpp @@ -33,13 +33,13 @@ hash_numbering value_set_fit::function_numbering; static const char *alloc_adapter_prefix="alloc_adaptor::"; #define forall_objects(it, map) \ - for(object_map_dt::const_iterator (it) = (map).begin(); \ - (it)!=(map).end(); \ + for(object_map_dt::const_iterator it = (map).begin(); \ + it!=(map).end(); \ (it)++) #define Forall_objects(it, map) \ - for(object_map_dt::iterator (it) = (map).begin(); \ - (it)!=(map).end(); \ + for(object_map_dt::iterator it = (map).begin(); \ + it!=(map).end(); \ (it)++) void value_set_fit::output( diff --git a/src/pointer-analysis/value_set_fivr.cpp b/src/pointer-analysis/value_set_fivr.cpp index 8255267d0ba..4e97223772d 100644 --- a/src/pointer-analysis/value_set_fivr.cpp +++ b/src/pointer-analysis/value_set_fivr.cpp @@ -33,24 +33,24 @@ hash_numbering value_set_fivrt::function_numbering; static const char *alloc_adapter_prefix="alloc_adaptor::"; #define forall_objects(it, map) \ - for(object_map_dt::const_iterator (it)=(map).begin(); \ - (it)!=(map).end(); \ + for(object_map_dt::const_iterator it=(map).begin(); \ + it!=(map).end(); \ (it)++) #define forall_valid_objects(it, map) \ - for(object_map_dt::const_iterator (it)=(map).begin(); \ - (it)!=(map).end(); \ + for(object_map_dt::const_iterator it=(map).begin(); \ + it!=(map).end(); \ (it)++) \ - if((map).is_valid_at((it)->first, from_function, from_target_index)) + if((map).is_valid_at(it->first, from_function, from_target_index)) #define Forall_objects(it, map) \ - for(object_map_dt::iterator (it)=(map).begin(); \ - (it)!=(map).end(); \ + for(object_map_dt::iterator it=(map).begin(); \ + it!=(map).end(); \ (it)++) #define Forall_valid_objects(it, map) \ - for(object_map_dt::iterator (it)=(map).begin(); \ - (it)!=(map).end(); \ + for(object_map_dt::iterator it=(map).begin(); \ + it!=(map).end(); \ (it)++) \ if((map).is_valid_at((it)->first, from_function, from_target_index)) /* NOLINT(*) */