aboutsummaryrefslogtreecommitdiff
path: root/test/dfsan/vararg.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/dfsan/vararg.c')
-rw-r--r--test/dfsan/vararg.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/dfsan/vararg.c b/test/dfsan/vararg.c
new file mode 100644
index 000000000000..2227ba715639
--- /dev/null
+++ b/test/dfsan/vararg.c
@@ -0,0 +1,24 @@
+// RUN: %clang_dfsan -m64 %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck %s
+// RUN: %run %t foo
+// RUN: %clang_dfsan -mllvm -dfsan-args-abi -m64 %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck %s
+// RUN: %run %t foo
+
+#include <stdio.h>
+
+int do_nothing(const char *format, ...) {
+ return 0;
+}
+
+int main(int argc, char **argv) {
+ int (*fp)(const char *, ...);
+
+ if (argc > 1)
+ fp = do_nothing;
+ else
+ fp = printf;
+
+ // CHECK: FATAL: DataFlowSanitizer: unsupported indirect call to vararg function printf
+ fp("hello %s\n", "world");
+}