1 /* Test for format checking of constant arrays. */
2 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
3 /* { dg-do compile } */
4 /* { dg-options "-std=gnu99 -Wformat=2" } */
6 extern int printf (const char *, ...);
8 const char a1[] = "foo";
9 const char a2[] = "foo%d";
10 const char b[3] = "foo";
11 static const char c1[] = "foo";
12 static const char c2[] = "foo%d";
14 volatile const char e[] = "foo";
19 const char p1[] = "bar";
20 const char p2[] = "bar%d";
21 static const char q1[] = "bar";
22 static const char q2[] = "bar%d";
25 printf (a2, l); /* { dg-warning "format" "wrong type with array" } */
26 printf (b); /* { dg-warning "unterminated" "unterminated array" } */
29 printf (c2, l); /* { dg-warning "format" "wrong type with array" } */
32 printf (p2, l); /* { dg-warning "format" "wrong type with array" } */
35 printf (q2, l); /* { dg-warning "format" "wrong type with array" } */
36 /* Volatile or non-constant arrays must not be checked. */
37 printf (d); /* { dg-warning "not a string literal" "non-const" } */
38 printf ((const char *)e); /* { dg-warning "not a string literal" "volatile" } */