xref: /aosp_15_r20/external/compiler-rt/test/dfsan/vararg.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clang_dfsan %s -o %t
2*7c3d14c8STreehugger Robot // RUN: not %run %t 2>&1 | FileCheck %s
3*7c3d14c8STreehugger Robot // RUN: %run %t foo
4*7c3d14c8STreehugger Robot // RUN: %clang_dfsan -mllvm -dfsan-args-abi %s -o %t
5*7c3d14c8STreehugger Robot // RUN: not %run %t 2>&1 | FileCheck %s
6*7c3d14c8STreehugger Robot // RUN: %run %t foo
7*7c3d14c8STreehugger Robot 
8*7c3d14c8STreehugger Robot #include <stdio.h>
9*7c3d14c8STreehugger Robot 
do_nothing(const char * format,...)10*7c3d14c8STreehugger Robot int do_nothing(const char *format, ...) {
11*7c3d14c8STreehugger Robot   return 0;
12*7c3d14c8STreehugger Robot }
13*7c3d14c8STreehugger Robot 
main(int argc,char ** argv)14*7c3d14c8STreehugger Robot int main(int argc, char **argv) {
15*7c3d14c8STreehugger Robot   int (*fp)(const char *, ...);
16*7c3d14c8STreehugger Robot 
17*7c3d14c8STreehugger Robot   if (argc > 1)
18*7c3d14c8STreehugger Robot     fp = do_nothing;
19*7c3d14c8STreehugger Robot   else
20*7c3d14c8STreehugger Robot     fp = printf;
21*7c3d14c8STreehugger Robot 
22*7c3d14c8STreehugger Robot   // CHECK: FATAL: DataFlowSanitizer: unsupported indirect call to vararg function printf
23*7c3d14c8STreehugger Robot   fp("hello %s\n", "world");
24*7c3d14c8STreehugger Robot }
25