diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-05-26 13:58:03 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-05-26 17:04:29 +0200 |
| commit | f88da50b475e3e5efdccfab1375ff6af6ae2b9ec (patch) | |
| tree | 795087dab7afa95161286077b8403beeb463e283 /validation | |
| parent | 63369a98d8ee0c72d28122539e4e542e62308ad2 (diff) | |
| download | sparse-dev-f88da50b475e3e5efdccfab1375ff6af6ae2b9ec.tar.gz | |
context: extra warning for __context__() & friends
Statements with an empty expression, like:
__context__();
or
__context__(x,);
are silently accepted. Worse, since NULL expressions are usually
ignored because it is assumed they have already been properly
diagnosticated, no warnings of any kind are given at some later
stage.
Fix this by explicitly checking after empty expressions and
emit an error message if needed.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/context-stmt.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/validation/context-stmt.c b/validation/context-stmt.c index 8cea6b5f..2884a8a2 100644 --- a/validation/context-stmt.c +++ b/validation/context-stmt.c @@ -16,6 +16,11 @@ static void foo(int x) __context__ x, 0); // KO: unmatched parens __context__(0; // KO: unmatched parens __context__ 0); // KO: unmatched parens + + __context__(); // KO: no expression at all + __context__(,0); // KO: no expression at all + __context__(x,); // KO: no expression at all + __context__(,); // KO: no expression at all } /* @@ -25,6 +30,8 @@ static void foo(int x) * check-error-start context-stmt.c:10:20: error: Expected ( after __context__ statement context-stmt.c:10:20: error: got ; +context-stmt.c:11:21: error: expression expected after '(' +context-stmt.c:11:21: error: got ; context-stmt.c:11:21: error: Expected ) at end of __context__ statement context-stmt.c:11:21: error: got ; context-stmt.c:13:21: error: Expected ( after __context__ statement @@ -39,6 +46,16 @@ context-stmt.c:17:22: error: Expected ) at end of __context__ statement context-stmt.c:17:22: error: got ; context-stmt.c:18:21: error: Expected ( after __context__ statement context-stmt.c:18:21: error: got 0 +context-stmt.c:20:21: error: expression expected after '(' +context-stmt.c:20:21: error: got ) +context-stmt.c:21:21: error: expression expected after '(' +context-stmt.c:21:21: error: got , +context-stmt.c:22:23: error: expression expected after ',' +context-stmt.c:22:23: error: got ) +context-stmt.c:23:21: error: expression expected after '(' +context-stmt.c:23:21: error: got , +context-stmt.c:23:22: error: expression expected after ',' +context-stmt.c:23:22: error: got ) context-stmt.c:7:21: error: bad constant expression context-stmt.c:8:23: error: bad constant expression * check-error-end |
