[PATCH 1/3] add testcase for __builtin_unreachable()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



__builtin_unreachable()'s semantic has consequences on the CFG
and this should be taken in account for:
* checking for undefined variables
* checking when control reaches end of non-void function
* context checking
* ...

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/linear/builtin_unreachable.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 validation/linear/builtin_unreachable.c

diff --git a/validation/linear/builtin_unreachable.c b/validation/linear/builtin_unreachable.c
new file mode 100644
index 000000000..4f13b892a
--- /dev/null
+++ b/validation/linear/builtin_unreachable.c
@@ -0,0 +1,31 @@
+void function_that_never_returns(void);
+
+int foo(int c)
+{
+	if (c)
+		return 1;
+	function_that_never_returns();
+	__builtin_unreachable();
+}
+
+/*
+ * check-name: __builtin_unreachable()
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-known-to-fail
+ * check-output-start
+foo:
+.L0:
+	<entry-point>
+	cbr         %arg1, .L3, .L2
+
+.L2:
+	call        function_that_never_returns
+	unreach
+
+.L3:
+	ret.32      $1
+
+
+ * check-output-end
+ */
-- 
2.14.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux