No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gcc4 / gcc / testsuite / gcc.dg / format / array-1.c
blobfa27abe1dee6774c9c1a943e4c777b96b11d3df7
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 #include "format.h"
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";
13 char d[] = "foo";
14 volatile const char e[] = "foo";
16 void
17 foo (int i, long l)
19 const char p1[] = "bar";
20 const char p2[] = "bar%d";
21 static const char q1[] = "bar";
22 static const char q2[] = "bar%d";
23 printf (a1);
24 printf (a2, i);
25 printf (a2, l); /* { dg-warning "format" "wrong type with array" } */
26 printf (b); /* { dg-warning "unterminated" "unterminated array" } */
27 printf (c1);
28 printf (c2, i);
29 printf (c2, l); /* { dg-warning "format" "wrong type with array" } */
30 printf (p1);
31 printf (p2, i);
32 printf (p2, l); /* { dg-warning "format" "wrong type with array" } */
33 printf (q1);
34 printf (q2, i);
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" } */