@@ -669,25 +669,29 @@ bool goto_programt::instructiont::equals(const instructiont &other) const
669669 // clang-format on
670670}
671671
672- bool goto_programt::instructiont::check_internal_invariants (
672+ void goto_programt::instructiont::validate (
673673 const symbol_tablet &table,
674- messaget &msg ) const
674+ const validation_modet &vm ) const
675675{
676676 namespacet ns (table);
677- bool found_violation = false ;
678677 std::vector<std::vector<std::string>> type_collector;
678+ std::stringstream location_stream;
679+ location_stream << source_location;
680+
679681 auto type_finder = [&](const exprt &e) {
680682 if (e.id () == ID_symbol)
681683 {
682684 auto symbol_expr = to_symbol_expr (e);
683685 const auto &symbol_id = symbol_expr.get_identifier ();
684- if (
685- table.has_symbol (symbol_id) &&
686- !base_type_eq (symbol_expr.type (), table.lookup_ref (symbol_id).type , ns))
687- type_collector.push_back (
688- {id2string (symbol_id),
689- symbol_expr.type ().id_string (),
690- table.lookup_ref (symbol_id).type .id_string ()});
686+
687+ if (table.has_symbol (symbol_id))
688+ DATA_CHECK (
689+ base_type_eq (
690+ symbol_expr.type (), table.lookup_ref (symbol_id).type , ns),
691+ id2string (symbol_id) + " type inconsistency (" +
692+ location_stream.str () + " )\n " + " goto program type: " +
693+ symbol_expr.type ().id_string () + " \n " + " symbol table type: " +
694+ table.lookup_ref (symbol_id).type .id_string ());
691695 }
692696 };
693697
@@ -719,20 +723,6 @@ bool goto_programt::instructiont::check_internal_invariants(
719723 case INCOMPLETE_GOTO:
720724 break ;
721725 }
722-
723- if (!type_collector.empty ())
724- {
725- for (const auto &type_triple : type_collector)
726- {
727- INVARIANT (type_triple.size () > 2 , " should have 3 elements" );
728- msg.error () << type_triple[0 ] << " type inconsistency ("
729- << source_location << " )\n "
730- << " goto program type: " << type_triple[1 ] << " \n "
731- << " symbol table type: " << type_triple[2 ] << messaget::eom;
732- }
733- found_violation = true ;
734- }
735- return found_violation;
736726}
737727
738728bool goto_programt::equals (const goto_programt &other) const
@@ -766,17 +756,14 @@ bool goto_programt::equals(const goto_programt &other) const
766756 return true ;
767757}
768758
769- bool goto_programt::check_internal_invariants (
759+ void goto_programt::validate (
770760 const symbol_tablet &table,
771- messaget &msg ) const
761+ const validation_modet &vm ) const
772762{
773- bool found_violation = false ;
774763 forall_goto_program_instructions (it, (*this ))
775764 {
776- found_violation =
777- found_violation || it->check_internal_invariants (table, msg);
765+ it->validate (table, vm);
778766 }
779- return found_violation;
780767}
781768
782769// / Outputs a string representation of a `goto_program_instruction_typet`
0 commit comments