aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-12-28 17:33:25 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-12-28 18:06:21 +0100
commitf1e3c9e9c9aef42c63519d3a6d77e52f3ffa6b53 (patch)
tree7b8aec92f6dbfb053b9ddd171806eadf51144e74 /validation
parent69a789a78d4e64052628307f25310e195a50f5ee (diff)
downloadsparse-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.c27
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
+ */