Skip to content

Commit 050b3ea

Browse files
committed
Avoid warning about not returning a value
1 parent 758b427 commit 050b3ea

21 files changed

+84
-10
lines changed

jbmc/src/java_bytecode/java_object_factory.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ static mp_integer max_value(const typet &type)
496496
else if(type.id() == ID_unsignedbv)
497497
return to_unsignedbv_type(type).largest();
498498
UNREACHABLE;
499+
return 0;
499500
}
500501

501502
/// Create code allocating object of size `size` and assigning it to `lhs`

jbmc/src/java_bytecode/java_utils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ resolve_inherited_componentt::inherited_componentt get_inherited_component(
406406
}
407407

408408
UNREACHABLE; // Unexpected access modifier
409+
return resolve_inherited_componentt::inherited_componentt();
409410
}
410411
else
411412
{

src/cbmc/bmc.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@ safety_checkert::resultt bmct::stop_on_fail(prop_convt &prop_conv)
543543

544544
return resultt::ERROR;
545545
}
546+
547+
UNREACHABLE;
548+
return resultt::ERROR;
546549
}
547550

548551
/// Perform core BMC, using an abstract model to supply GOTO function bodies
@@ -672,6 +675,7 @@ int bmct::do_language_agnostic_bmc(
672675
UNREACHABLE;
673676
}
674677
UNREACHABLE;
678+
return CPROVER_EXIT_INTERNAL_ERROR;
675679
}
676680

677681
void bmct::perform_symbolic_execution(

src/cbmc/fault_localization.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ safety_checkert::resultt fault_localizationt::stop_on_fail()
317317

318318
return safety_checkert::resultt::ERROR;
319319
}
320+
321+
UNREACHABLE;
322+
return safety_checkert::resultt::ERROR;
320323
}
321324

322325
void fault_localizationt::goal_covered(

src/cpp/cpp_id.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <ostream>
1515

16+
#include <util/invariant.h>
17+
1618
#include "cpp_scope.h"
1719

1820
cpp_idt::cpp_idt():
@@ -119,4 +121,7 @@ std::ostream &operator<<(std::ostream &out, const cpp_idt::id_classt &id_class)
119121
case cpp_idt::id_classt::NAMESPACE: return out<<"NAMESPACE";
120122
case cpp_idt::id_classt::ENUM: return out<<"ENUM";
121123
}
124+
125+
UNREACHABLE;
126+
return out;
122127
}

src/goto-cc/compile.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ bool compilet::add_input_file(const std::string &file_name)
217217
}
218218

219219
UNREACHABLE;
220+
return false;
220221
}
221222

222223
/// extracts goto binaries from AR archive and add them as input files.

src/goto-instrument/accelerate/polynomial.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ int monomialt::compare(monomialt &other)
410410
}
411411

412412
UNREACHABLE;
413+
return -1;
413414
}
414415

415416
int polynomialt::max_degree(const exprt &var)

src/goto-instrument/accelerate/util.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,5 @@ typet join_types(const typet &t1, const typet &t2)
119119
<< '\n';
120120

121121
INVARIANT(false, "failed to join types");
122+
return nil_typet();
122123
}

src/goto-programs/format_strings.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ Author: CM Wintersteiger
1111

1212
#include "format_strings.h"
1313

14-
#include <util/std_types.h>
15-
#include <util/std_expr.h>
16-
1714
#include <util/c_types.h>
15+
#include <util/invariant.h>
16+
#include <util/std_expr.h>
17+
#include <util/std_types.h>
1818

1919
#include <cctype>
2020

@@ -309,4 +309,7 @@ typet get_type(const format_tokent &token)
309309
case format_tokent::token_typet::UNKNOWN:
310310
return nil_typet();
311311
}
312+
313+
UNREACHABLE;
314+
return nil_typet();
312315
}

src/goto-programs/goto_program.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]
1414
#include <ostream>
1515
#include <iomanip>
1616

17+
#include <util/invariant.h>
1718
#include <util/std_expr.h>
1819

1920
#include <langapi/language_util.h>
@@ -515,6 +516,9 @@ std::string as_string(
515516
case INCOMPLETE_GOTO:
516517
return "(INCOMPLETE GOTO)";
517518
}
519+
520+
UNREACHABLE;
521+
return "";
518522
}
519523

520524
void goto_programt::compute_loop_numbers()

src/goto-programs/remove_complex.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ static exprt complex_member(const exprt &expr, irep_idt id)
2727
return expr.op0();
2828
else if(id==ID_imag)
2929
return expr.op1();
30-
else
31-
UNREACHABLE;
30+
31+
UNREACHABLE;
32+
return nil_exprt();
3233
}
3334
else
3435
{

src/goto-programs/safety_checker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ operator&=(safety_checkert::resultt &a, safety_checkert::resultt const &b)
9191
UNREACHABLE;
9292
}
9393
UNREACHABLE;
94+
return a;
9495
}
9596

9697
/// \brief The best of two results

src/solvers/flattening/boolbv_bitwise.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,5 @@ bvt boolbvt::convert_bitwise(const exprt &expr)
6464
}
6565

6666
UNIMPLEMENTED;
67+
return bvt();
6768
}

src/solvers/flattening/bv_utils.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,10 @@ literalt bv_utilst::overflow_add(
385385
return carry_out(op0, op1, const_literal(false));
386386
}
387387
else
388+
{
388389
UNREACHABLE;
390+
return literalt();
391+
}
389392
}
390393

391394
literalt bv_utilst::overflow_sub(
@@ -410,7 +413,10 @@ literalt bv_utilst::overflow_sub(
410413
return !carry_out(op0, inverted(op1), const_literal(true));
411414
}
412415
else
416+
{
413417
UNREACHABLE;
418+
return literalt();
419+
}
414420
}
415421

416422
void bv_utilst::adder_no_overflow(
@@ -816,8 +822,10 @@ bvt bv_utilst::multiplier(
816822
{
817823
case representationt::SIGNED: return signed_multiplier(op0, op1);
818824
case representationt::UNSIGNED: return unsigned_multiplier(op0, op1);
819-
default: UNREACHABLE;
820825
}
826+
827+
UNREACHABLE;
828+
return bvt();
821829
}
822830

823831
bvt bv_utilst::multiplier_no_overflow(
@@ -831,8 +839,10 @@ bvt bv_utilst::multiplier_no_overflow(
831839
return signed_multiplier_no_overflow(op0, op1);
832840
case representationt::UNSIGNED:
833841
return unsigned_multiplier_no_overflow(op0, op1);
834-
default: UNREACHABLE;
835842
}
843+
844+
UNREACHABLE;
845+
return bvt();
836846
}
837847

838848
void bv_utilst::signed_divider(
@@ -885,7 +895,6 @@ void bv_utilst::divider(
885895
signed_divider(op0, op1, result, remainer); break;
886896
case representationt::UNSIGNED:
887897
unsigned_divider(op0, op1, result, remainer); break;
888-
default: assert(false);
889898
}
890899
}
891900

@@ -1297,7 +1306,10 @@ literalt bv_utilst::rel(
12971306
else if(id==ID_gt)
12981307
return lt_or_le(false, bv1, bv0, rep); // swapped
12991308
else
1309+
{
13001310
UNREACHABLE;
1311+
return literalt();
1312+
}
13011313
}
13021314

13031315
bool bv_utilst::is_constant(const bvt &bv)

src/solvers/prop/prop_conv.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ decision_proceduret::resultt prop_conv_solvert::dec_solve()
480480
case propt::resultt::P_UNSATISFIABLE: return resultt::D_UNSATISFIABLE;
481481
case propt::resultt::P_ERROR: return resultt::D_ERROR;
482482
}
483+
484+
UNREACHABLE;
485+
return resultt::D_ERROR;
483486
}
484487

485488
exprt prop_conv_solvert::get(const exprt &expr) const

src/solvers/refinement/bv_refinement_loop.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ decision_proceduret::resultt bv_refinementt::prop_solve()
110110
case propt::resultt::P_UNSATISFIABLE: return resultt::D_UNSATISFIABLE;
111111
case propt::resultt::P_ERROR: return resultt::D_ERROR;
112112
}
113+
114+
UNREACHABLE;
115+
return resultt::D_ERROR;
113116
}
114117

115118
void bv_refinementt::check_SAT()

src/solvers/refinement/string_builtin_function.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ class string_insertion_builtin_functiont : public string_builtin_functiont
190190
if(args.size() == 3)
191191
UNIMPLEMENTED;
192192
UNREACHABLE;
193+
return nil_exprt();
193194
};
194195

195196
exprt length_constraint() const override
@@ -199,6 +200,7 @@ class string_insertion_builtin_functiont : public string_builtin_functiont
199200
if(args.size() == 3)
200201
UNIMPLEMENTED;
201202
UNREACHABLE;
203+
return nil_exprt();
202204
};
203205

204206
bool maybe_testing_function() const override
@@ -246,6 +248,7 @@ class string_concatenation_builtin_functiont final
246248
return generator.add_axioms_for_concat_substr(
247249
result, input1, input2, args[0], args[1]);
248250
UNREACHABLE;
251+
return nil_exprt();
249252
};
250253

251254
exprt length_constraint() const override
@@ -256,6 +259,7 @@ class string_concatenation_builtin_functiont final
256259
return length_constraint_for_concat_substr(
257260
result, input1, input2, args[0], args[1]);
258261
UNREACHABLE;
262+
return nil_exprt();
259263
}
260264
};
261265

@@ -337,6 +341,7 @@ class string_builtin_function_with_no_evalt : public string_builtin_functiont
337341
// For now, there is no need for implementing that as `add_constraints`
338342
// should always be called on these functions
339343
UNIMPLEMENTED;
344+
return nil_exprt();
340345
}
341346
};
342347

src/solvers/smt2/smt2_parser.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Author: Daniel Kroening, [email protected]
99
#include "smt2_parser.h"
1010

1111
#include <util/arith_tools.h>
12+
#include <util/invariant.h>
1213

1314
void smt2_parsert::command_sequence()
1415
{
@@ -873,6 +874,9 @@ exprt smt2_parsert::function_application()
873874

874875
return tmp;
875876
}
877+
878+
UNREACHABLE;
879+
return nil_exprt();
876880
}
877881

878882
exprt smt2_parsert::expression()
@@ -939,6 +943,9 @@ exprt smt2_parsert::expression()
939943
error() << "unexpected token in an expression" << eom;
940944
return nil_exprt();
941945
}
946+
947+
UNREACHABLE;
948+
return nil_exprt();
942949
}
943950

944951
typet smt2_parsert::sort()
@@ -1014,6 +1021,9 @@ typet smt2_parsert::sort()
10141021
error() << "unexpected token in a sort " << buffer << eom;
10151022
return nil_typet();
10161023
}
1024+
1025+
UNREACHABLE;
1026+
return nil_typet();
10171027
}
10181028

10191029
typet smt2_parsert::function_signature_definition()

src/util/byte_operators.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ irep_idt byte_extract_id()
2424
return ID_byte_extract_big_endian;
2525

2626
case configt::ansi_ct::endiannesst::NO_ENDIANNESS:
27-
UNREACHABLE;
27+
break;
2828
}
29+
30+
UNREACHABLE;
31+
return ID_nil;
2932
}
3033

3134
irep_idt byte_update_id()
@@ -39,6 +42,9 @@ irep_idt byte_update_id()
3942
return ID_byte_update_big_endian;
4043

4144
case configt::ansi_ct::endiannesst::NO_ENDIANNESS:
42-
UNREACHABLE;
45+
break;
4346
}
47+
48+
UNREACHABLE;
49+
return ID_nil;
4450
}

src/util/c_types.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ unsignedbv_typet size_type()
6868
else if(config.ansi_c.pointer_width==config.ansi_c.long_long_int_width)
6969
return unsigned_long_long_int_type();
7070
else
71+
{
7172
INVARIANT(false, "width of size type"); // aaah!
73+
return unsignedbv_typet(0);
74+
}
7275
}
7376

7477
signedbv_typet signed_size_type()
@@ -237,7 +240,10 @@ signedbv_typet pointer_diff_type()
237240
else if(config.ansi_c.pointer_width==config.ansi_c.long_long_int_width)
238241
return signed_long_long_int_type();
239242
else
243+
{
240244
INVARIANT(false, "width of pointer difference");
245+
return signedbv_typet(0);
246+
}
241247
}
242248

243249
pointer_typet pointer_type(const typet &subtype)

src/util/config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,8 @@ std::string configt::ansi_ct::os_to_string(ost os)
10471047
case ost::OS_WIN: return "win";
10481048
case ost::NO_OS: return "none";
10491049
}
1050+
UNREACHABLE;
1051+
return "";
10501052
}
10511053

10521054
configt::ansi_ct::ost configt::ansi_ct::string_to_os(const std::string &os)

0 commit comments

Comments
 (0)