File tree Expand file tree Collapse file tree 5 files changed +52
-3
lines changed
regression/ansi-c/linking_contracts1 Expand file tree Collapse file tree 5 files changed +52
-3
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdbool.h>
2
+
3
+ bool util_func (int a )
4
+ // clang-format off
5
+ __CPROVER_ensures (
6
+ __CPROVER_return_value == true || __CPROVER_return_value == false )
7
+ // clang-format on
8
+ {
9
+ if (a > 0 )
10
+ {
11
+ return true;
12
+ }
13
+ else
14
+ {
15
+ return false;
16
+ }
17
+ }
18
+
19
+ int test1 (int a );
20
+ int test2 (int a );
Original file line number Diff line number Diff line change
1
+ #include "header.h"
2
+
3
+ int test1 (int a )
4
+ {
5
+ return util_func (a );
6
+ }
Original file line number Diff line number Diff line change
1
+ #include "header.h"
2
+
3
+ int test2 (int a )
4
+ {
5
+ return util_func (a );
6
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ module.c
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ --
7
+ ^warning: ignoring
8
+ ^CONVERSION ERROR$
9
+ conflict on code contract
10
+ --
11
+ This test makes sure we support contracts in header files, which may then end up
12
+ in multiple translation units.
Original file line number Diff line number Diff line change @@ -1105,10 +1105,15 @@ void linkingt::duplicate_non_type_symbol(
1105
1105
symbolt &old_symbol,
1106
1106
symbolt &new_symbol)
1107
1107
{
1108
- // we do not permit multiple contracts to be defined, or cases where only one
1109
- // of the symbols is a contract
1110
- if (old_symbol.is_property || new_symbol.is_property )
1108
+ // we do not permit different contracts with the same name to be defined, or
1109
+ // cases where only one of the symbols is a contract
1110
+ if (
1111
+ old_symbol.is_property != new_symbol.is_property ||
1112
+ (old_symbol.is_property && new_symbol.is_property &&
1113
+ old_symbol.type != new_symbol.type ))
1114
+ {
1111
1115
link_error (old_symbol, new_symbol, " conflict on code contract" );
1116
+ }
1112
1117
1113
1118
// see if it is a function or a variable
1114
1119
You can’t perform that action at this time.
0 commit comments