Skip to content

Fix errors emitted by C++2a compiler #1973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/cpp/cpp_typecheck_resolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/goto-instrument/cover_basic_blocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/goto-instrument/cover_instrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/java_bytecode/java_bytecode_parse_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Author: Daniel Kroening, [email protected]
class java_bytecode_parse_treet
{
public:
virtual ~java_bytecode_parse_treet() = default;
class annotationt
{
public:
Expand Down Expand Up @@ -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;
};
Expand Down
8 changes: 4 additions & 4 deletions src/pointer-analysis/value_set_fi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ hash_numbering<irep_idt, irep_id_hash> 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)++)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good reason to get rid of those macros (just the ones here, not all forall_*/Forall_*). The use of auto or ranged-for loop make them unnecessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely, see e.g. pointer-analysis/value_set_fivr.cpp:202:

      object_map_dt::const_iterator next(o_it);
      next++;

      if(next!=object_map.read().end())
      {
        out << "\n      ";
      }

I cannot construct an iterator from the value ranged over by for(auto const &...), do you have a suggestion on how to deal with this case?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But using for(auto o_it = bla.begin(); o_it != bla.end(); ++o_it) should still work, shouldn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same discussion has gone around a few times here -- our conclusion was "keep them, but only for cases where you need an explicit iterator and so a for-each loop won't do the trick"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your reviews are conflicting: I can use a ranged-for loop when I can, but where I cannot, shall I keep the macro (without the parentheses) or write the loop header explicitly with auto?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favour of removing this macro (because it's broken).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macros are pre-ranged-for, and should likely disappear.


#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(
Expand Down
18 changes: 9 additions & 9 deletions src/pointer-analysis/value_set_fivr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ hash_numbering<irep_idt, irep_id_hash> 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(*) */

Expand Down