diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-05-24 02:01:21 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-05-26 17:04:29 +0200 |
| commit | 02510ae80084b9446d9afda779c0c4a3385eb22d (patch) | |
| tree | 3479d8f1060d550364038379c75458db5f617605 /validation | |
| parent | 8e9e4da4790a071c6fa0dd5bf99036c36b5d5fbd (diff) | |
| download | sparse-dev-02510ae80084b9446d9afda779c0c4a3385eb22d.tar.gz | |
context: __context__(...) expect a constant expression
No check are done if the inc/dec value of context statements
is effectively a compile-time integer value: '0' is silently
used if it is not.
Change that by using get_expression_value() when linearizing
context statements (which has the added advantage to also
slightly simplify the code).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/context-stmt.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/validation/context-stmt.c b/validation/context-stmt.c new file mode 100644 index 00000000..cb85e562 --- /dev/null +++ b/validation/context-stmt.c @@ -0,0 +1,19 @@ +static void foo(int x) +{ + __context__(0); // OK + __context__(x, 0); // OK + __context__ (x, 1); // OK + + __context__(x); // KO: no const expr + __context__(1,x); // KO: no const expr +} + +/* + * check-name: context-stmt + * check-command: sparse -Wno-context $file + * + * check-error-start +context-stmt.c:7:21: error: bad constant expression +context-stmt.c:8:23: error: bad constant expression + * check-error-end + */ |
