]> pd.if.org Git - lice/blobdiff - tests/returnaddr.c
autocommit for files dated 2014-11-17 20:13:36
[lice] / tests / returnaddr.c
diff --git a/tests/returnaddr.c b/tests/returnaddr.c
new file mode 100644 (file)
index 0000000..f4c2cc0
--- /dev/null
@@ -0,0 +1,25 @@
+// __builtin_return_address
+
+static void *a(void) {
+    return __builtin_return_address(1);
+}
+
+static void *b(void) {
+    expecti(__builtin_return_address(0), a());
+    return __builtin_return_address(0);
+}
+
+static void *c(void) {
+_1:
+    void *this = b();
+_2:
+    expecti((&&_1 < this && this <= &&_2), 1);
+
+    return this;
+}
+
+int main(void) {
+    expecti(c() <= b(), 1);
+
+    return 0;
+}