forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving linker warning diagnostics
We previously just reported pointer type conflicts without elaborating what the exact difference was. To produce type-consistent goto programs, we chose to use the type that the definition had, but lacked any test that doing so would actually result in a program that can be analysed successfully. This commit fixes bugs in the code producing diagnostics, enables diagnostics for the case of pointer type conflicts, and adds a test to demonstrate that we successfully analyse programs after type conflict resolution. Despite this, however, inconsistencies in the goto program remain: the call types still need fixing up. Fixes: diffblue#198
- Loading branch information
1 parent
8b5d37a
commit e24cb3f
Showing
7 changed files
with
148 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CORE | ||
typesmain.c | ||
types1.c types2.c types3.c --verbosity 2 | ||
reason for conflict at \*#this.u: number of members is different \(3/0\) | ||
reason for conflict at \*#this.u: number of members is different \(0/3\) | ||
struct U \(incomplete\) | ||
warning: pointer parameter types differ between declaration and definition "bar" | ||
warning: pointer parameter types differ between declaration and definition "foo" | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
struct S | ||
{ | ||
int s; | ||
} s_object; | ||
|
||
int foobar() | ||
{ | ||
return s_object.s; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
struct S | ||
{ | ||
struct T *t; | ||
struct U *u; | ||
}; | ||
|
||
struct U | ||
{ | ||
struct S *s; | ||
int j; | ||
}; | ||
|
||
int bar(struct S *s) | ||
{ | ||
return s->u->j; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
struct T | ||
{ | ||
int i; | ||
}; | ||
|
||
struct S | ||
{ | ||
struct T *t; | ||
struct U *u; | ||
}; | ||
|
||
int bar(struct S *); | ||
|
||
int foo(struct S *s) | ||
{ | ||
return bar(s) + s->t->i; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <assert.h> | ||
|
||
struct T | ||
{ | ||
int i; | ||
}; | ||
|
||
struct U | ||
{ | ||
struct S *s; | ||
int j; | ||
}; | ||
|
||
struct S | ||
{ | ||
struct T *t; | ||
struct U *u; | ||
}; | ||
|
||
int foo(struct S *s); | ||
|
||
int main() | ||
{ | ||
struct T t = {10}; | ||
struct U u = {0, 32}; | ||
struct S s = {&t, &u}; | ||
int res = foo(&s); | ||
assert(res == 42); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters