Skip to content

Commit aef9f3f

Browse files
Merge pull request #6152 from thomasspriggs/tas/unimplemented_feature
Add UNIMPLEMENTED_FEATURE macro
2 parents f82fea4 + 590fa37 commit aef9f3f

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/util/invariant.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,9 @@ CBMC_NORETURN void report_invariant_failure(
514514
#define DATA_INVARIANT_STRUCTURED(CONDITION, TYPENAME, ...) \
515515
EXPAND_MACRO(INVARIANT_STRUCTURED(CONDITION, TYPENAME, __VA_ARGS__))
516516

517+
#define UNIMPLEMENTED_FEATURE(FEATURE) \
518+
INVARIANT(false, std::string{"Reached unimplemented "} + (FEATURE))
519+
517520
// Legacy annotations
518521

519522
// The following should not be used in new code and are only intended

unit/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ SRC += analyses/ai/ai.cpp \
114114
util/interval_union.cpp \
115115
util/irep.cpp \
116116
util/irep_sharing.cpp \
117+
util/invariant.cpp \
117118
util/json_array.cpp \
118119
util/json_object.cpp \
119120
util/lazy.cpp \

unit/util/invariant.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Author: Diffblue Ltd.
2+
3+
/// \file Tests for macros in src/util/invariant.h
4+
5+
#include <testing-utils/invariant.h>
6+
#include <testing-utils/use_catch.h>
7+
8+
#include <util/invariant.h>
9+
10+
TEST_CASE("Using the UNIMPLEMENTED macro", "[invariant]")
11+
{
12+
cbmc_invariants_should_throwt invariants_throw;
13+
REQUIRE_THROWS_MATCHES(
14+
[]() { UNIMPLEMENTED; }(),
15+
invariant_failedt,
16+
invariant_failure_containing("Reason: Unimplemented"));
17+
}
18+
19+
TEST_CASE("Using the UNIMPLEMENTED_FEATURE macro", "[invariant]")
20+
{
21+
cbmc_invariants_should_throwt invariants_throw;
22+
REQUIRE_THROWS_MATCHES(
23+
[]() { UNIMPLEMENTED_FEATURE("example"); }(),
24+
invariant_failedt,
25+
invariant_failure_containing("Reason: Reached unimplemented example"));
26+
}

0 commit comments

Comments
 (0)