Debian Codegraph @

gcc/testsuite/gcc.dg/format/gcc_gfc-1.c

raw
1 /* Test for gcc_gfc formats. */
2 /* Origin: Kaveh Ghazi <[email protected]> */
3 /* { dg-do compile } */
4 /* { dg-options "-Wformat" } */
5
6 #include "format.h"
7
8 /* Magic identifier must be set before the attribute is used. */
9 typedef struct locus locus;
10
11 extern int gfc_warn (const char *, ...) __attribute__ ((__format__ (__gcc_gfc__, 1, 2))) __attribute__ ((__nonnull__));
12
13 void
14 foo (unsigned int u, int i, char *s, unsigned long int ul, long int l,
15 llong ll, unsigned long long int ull, locus *loc, size_t sz,
16 ptrdiff_t pd, ssize_t ssz, unsigned_ptrdiff_t upd)
17 {
18 /* Acceptable C90 specifiers, flags and modifiers. */
19 gfc_warn ("%%");
20 gfc_warn ("%u%d%i%c%s%%", u, i, i, i, s);
21 gfc_warn ("%lu%ld%li%%", ul, l, l);
22
23 /* Acceptable C99 specifiers, flags and modifiers. */
24 gfc_warn ("%llu%lld%lli%%", ull, ll, ll);
25 gfc_warn ("%zu%zd%zi%%", sz, ssz, ssz);
26 gfc_warn ("%tu%td%ti%%", upd, pd, pd);
27
28 /* Extensions provided in gfc_warn. */
29 gfc_warn ("%C");
30 gfc_warn ("%L", loc);
31
32 /* Various tests of bad argument types. */
33 gfc_warn ("%d", l); /* { dg-warning "format" "bad argument types" } */
34 gfc_warn ("%d", ll); /* { dg-warning "format" "bad argument types" } */
35 gfc_warn ("%s", &i); /* { dg-warning "format" "bad argument types" } */
36 gfc_warn ("%L", &i); /* { dg-warning "format" "bad argument types" } */
37 gfc_warn ("%C", i); /* { dg-warning "format" "too many arguments" } */
38 }