diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-12-28 17:33:25 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-12-28 18:06:21 +0100 |
| commit | f1e3c9e9c9aef42c63519d3a6d77e52f3ffa6b53 (patch) | |
| tree | 7b8aec92f6dbfb053b9ddd171806eadf51144e74 /validation | |
| parent | 69a789a78d4e64052628307f25310e195a50f5ee (diff) | |
| download | sparse-dev-f1e3c9e9c9aef42c63519d3a6d77e52f3ffa6b53.tar.gz | |
warn on empty parenthesized expressions
Empty sub-expressions are normally caught as syntax error
in most expressions but this is not the case for parenthesized
expressions.
Fix this by adding a check at the end of parens_expressions()
and warning if needed.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/empty-expr.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/validation/empty-expr.c b/validation/empty-expr.c new file mode 100644 index 00000000..506cfba7 --- /dev/null +++ b/validation/empty-expr.c @@ -0,0 +1,27 @@ +static int foo(void) +{ + switch () { + case 0: + return 0; + default: + return 1; + } +} + +static int bar(void) +{ + if () + return 0; + else + return 1; +} + +/* + * check-name: empty expression + * check-known-to-fail + * + * check-error-start +empty-expr.c:3:17: error: an expression is expected before ')' +empty-expr.c:13:13: error: an expression is expected before ')' + * check-error-end + */ |
