annotate gcc/testsuite/gcc.dg/format/ms_array-1.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for format checking of constant arrays. */
kono
parents:
diff changeset
2 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
kono
parents:
diff changeset
3 /* { dg-do compile { target { *-*-mingw* } } } */
kono
parents:
diff changeset
4 /* { dg-options "-std=gnu99 -Wformat=2" } */
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 #define USE_SYSTEM_FORMATS
kono
parents:
diff changeset
7 #include "format.h"
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 const char a1[] = "foo";
kono
parents:
diff changeset
10 const char a2[] = "foo%d";
kono
parents:
diff changeset
11 const char b1[3] = "foo";
kono
parents:
diff changeset
12 const char b2[1] = "1";
kono
parents:
diff changeset
13 static const char c1[] = "foo";
kono
parents:
diff changeset
14 static const char c2[] = "foo%d";
kono
parents:
diff changeset
15 char d[] = "foo";
kono
parents:
diff changeset
16 volatile const char e[] = "foo";
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 void
kono
parents:
diff changeset
19 foo (int i, long l)
kono
parents:
diff changeset
20 {
kono
parents:
diff changeset
21 const char p1[] = "bar";
kono
parents:
diff changeset
22 const char p2[] = "bar%d";
kono
parents:
diff changeset
23 static const char q1[] = "bar";
kono
parents:
diff changeset
24 static const char q2[] = "bar%d";
kono
parents:
diff changeset
25 printf (a1);
kono
parents:
diff changeset
26 printf (a2, i);
kono
parents:
diff changeset
27 printf (a2, l); /* { dg-warning "format" "wrong type with array" } */
kono
parents:
diff changeset
28 printf (b1); /* { dg-warning "unterminated" "unterminated array" } */
kono
parents:
diff changeset
29 printf (b2); /* { dg-warning "unterminated" "unterminated array" } */
kono
parents:
diff changeset
30 printf (c1);
kono
parents:
diff changeset
31 printf (c2, i);
kono
parents:
diff changeset
32 printf (c2, l); /* { dg-warning "format" "wrong type with array" } */
kono
parents:
diff changeset
33 printf (p1);
kono
parents:
diff changeset
34 printf (p2, i);
kono
parents:
diff changeset
35 printf (p2, l); /* { dg-warning "format" "wrong type with array" } */
kono
parents:
diff changeset
36 printf (q1);
kono
parents:
diff changeset
37 printf (q2, i);
kono
parents:
diff changeset
38 printf (q2, l); /* { dg-warning "format" "wrong type with array" } */
kono
parents:
diff changeset
39 /* Volatile or non-constant arrays must not be checked. */
kono
parents:
diff changeset
40 printf (d); /* { dg-warning "not a string literal" "non-const" } */
kono
parents:
diff changeset
41 printf ((const char *)e); /* { dg-warning "not a string literal" "volatile" } */
kono
parents:
diff changeset
42 }