xref: /llvm-project/clang/test/Sema/format-strings.c (revision b87b1b36eea885786dface81cf487eaffec58796)
1 // RUN: clang -parse-ast-check %s
2 
3 #include <stdio.h>
4 #include <stdarg.h>
5 
6 void check_string_literal( FILE* fp, const char* s, char *buf, ... ) {
7 
8   char * b;
9   va_list ap;
10   va_start(ap,buf);
11 
12   printf(s); // expected-warning {{format string is not a string literal}}
13   vprintf(s,ap); // expected-warning {{format string is not a string liter}}
14   fprintf(fp,s); // expected-warning {{format string is not a string literal}}
15   vfprintf(fp,s,ap); // expected-warning {{format string is not a string lit}}
16   asprintf(&b,s); // expected-warning {{format string is not a string lit}}
17   vasprintf(&b,s,ap); // expected-warning {{format string is not a string lit}}
18   sprintf(buf,s); // expected-warning {{format string is not a string literal}}
19   snprintf(buf,2,s); // expected-warning {{format string is not a string lit}}
20   vsprintf(buf,s,ap); // expected-warning {{format string is not a string lit}}
21   vsnprintf(buf,2,s,ap); // expected-warning {{mat string is not a string lit}}
22 }
23 
24