aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/linear/range-op.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-02-17 10:37:24 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-05-06 16:38:35 +0200
commit1f5c32f43fb1e52fe6a81512b71a539b96ee8c31 (patch)
tree9a6a1c890ef319531b51c590b394314920641e95 /validation/linear/range-op.c
parent551b85c8a241bd45b267db152eca4cb01eddce39 (diff)
downloadsparse-dev-1f5c32f43fb1e52fe6a81512b71a539b96ee8c31.tar.gz
use function-like syntax for __range__
One of sparse's extension to the C language is an operator to check ranges. This operator takes 3 operands: the expression to be checked and the bounds. The syntax for this operator is such that the operands need to be a 3-items comma separated expression. This is a bit weird and doesn't play along very well with macros, for example. Change the syntax to a 3-arguments function-like operator. NB. Of course, this will break all existing uses of this extension not using parenthesis around the comma expression but there doesn't seems to be any. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/linear/range-op.c')
-rw-r--r--validation/linear/range-op.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/validation/linear/range-op.c b/validation/linear/range-op.c
new file mode 100644
index 00000000..4472bb33
--- /dev/null
+++ b/validation/linear/range-op.c
@@ -0,0 +1,31 @@
+static void foo(int a)
+{
+ __range__(a, 0, 8);
+}
+
+static void bar(int a, int b, int c)
+{
+ __range__(a, b, c);
+}
+
+/*
+ * check-name: range-op
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-start
+foo:
+.L0:
+ <entry-point>
+ range-check %arg1 between $0..$8
+ ret
+
+
+bar:
+.L2:
+ <entry-point>
+ range-check %arg1 between %arg2..%arg3
+ ret
+
+
+ * check-output-end
+ */