diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-12-09 23:35:03 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-12-09 23:35:03 +0100 |
| commit | 3243829828c3052efa55fc866e46c4c8d23b4400 (patch) | |
| tree | f456ec21ab82a507729d96c5df1060bdb655818b /validation | |
| parent | 82dee2e25887f26df7126d6789a419eaf14beb8c (diff) | |
| parent | 82d8c05866c84a04cc5ecba74365573b4c29fcbc (diff) | |
| download | sparse-dev-3243829828c3052efa55fc866e46c4c8d23b4400.tar.gz | |
Merge branch 'premature-examine' into next
* fix premature examination of dereferenced object
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/eval/premature-examination.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/validation/eval/premature-examination.c b/validation/eval/premature-examination.c new file mode 100644 index 00000000..bd2ffa90 --- /dev/null +++ b/validation/eval/premature-examination.c @@ -0,0 +1,27 @@ +extern int i; + +int foo(void) +{ + return *i; +} + +int bar(void) +{ + return i[0]; +} + +int *qux(void) +{ + return &i[0]; +} + +/* + * check-name: premature-examination + * check-command: sparse -Wno-decl $file + * + * check-error-start +eval/premature-examination.c:5:16: error: cannot dereference this type +eval/premature-examination.c:10:17: error: cannot dereference this type +eval/premature-examination.c:15:18: error: cannot dereference this type + * check-error-end + */ |
