libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / spellcheck-inttypes.c
blob084a5cd43140031ecd8b16bb9de624dba6f35b70
1 /* { dg-options "-std=c99" } */
2 /* Prevent AIX from implicitly including inttypes.h. */
3 #ifdef _AIX
4 #define _STD_TYPES_T
5 #endif
7 /* Prevent AVR-LibC from implicitly including inttypes.h. */
8 #ifdef __AVR__
9 #define __INTTYPES_H_
10 #include <stdint.h>
11 #endif
13 #include <stdio.h>
14 #include <stdint.h>
15 /* Missing <inttypes.h>. */
17 int8_t i8;
18 int16_t i16;
19 int32_t i32;
20 int64_t i64;
22 intptr_t ip;
23 uintptr_t up;
25 /* As an identifier. */
26 const char *hex8_fmt = PRIx8; /* { dg-error "'PRIx8' undeclared" "undeclared identifier" { target *-*-* } } */
27 /* { dg-message "'PRIx8' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
28 const char *hex16_fmt = PRIx16; /* { dg-error "'PRIx16' undeclared" "undeclared identifier" { target *-*-* } } */
29 /* { dg-message "'PRIx16' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
30 const char *hex32_fmt = PRIx32; /* { dg-error "'PRIx32' undeclared" "undeclared identifier" { target *-*-* } } */
31 /* { dg-message "'PRIx32' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
32 const char *hex64_fmt = PRIx64; /* { dg-error "'PRIx64' undeclared" "undeclared identifier" { target *-*-* } } */
33 /* { dg-message "'PRIx64' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
34 const char *hexptr_fmt = PRIxPTR; /* { dg-error "'PRIxPTR' undeclared" "undeclared identifier" { target *-*-* } } */
35 /* { dg-message "'PRIxPTR' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
37 /* As a part of a string-literal. */
38 const char *dec8msg_fmt = "Provide %" PRId8 "\n"; /* { dg-error "expected" "expected string-literal" { target *-*-* } } */
39 /* { dg-message "'PRId8' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
40 const char *dec16msg_fmt = "Provide %" PRId16 "\n"; /* { dg-error "expected" "expected string-literal" { target *-*-* } } */
41 /* { dg-message "'PRId16' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
42 const char *dec32msg_fmt = "Provide %" PRId32 "\n"; /* { dg-error "expected" "expected string-literal" { target *-*-* } } */
43 /* { dg-message "'PRId32' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
44 const char *dec64msg_fmt = "Provide %" PRId64 "\n"; /* { dg-error "expected" "expected string-literal" { target *-*-* } } */
45 /* { dg-message "'PRId64' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
46 const char *decptrmsg_fmt = "Provide %" PRIdPTR "\n"; /* { dg-error "expected" "expected string-literal" { target *-*-* } } */
47 /* { dg-message "'PRIdPTR' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
49 void test_printf (void)
51 printf ("some format strings %s, %s, %s, %s, %s, %s\n",
52 PRId8, /* { dg-error "'PRId8' undeclared" "undeclared identifier" { target *-*-* } } */
53 /* { dg-message "'PRId8' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
54 PRIi16, /* { dg-error "'PRIi16' undeclared" "undeclared identifier" { target *-*-* } } */
55 /* { dg-message "'PRIi16' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
56 PRIo32, /* { dg-error "'PRIo32' undeclared" "undeclared identifier" { target *-*-* } } */
57 /* { dg-message "'PRIo32' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
58 PRIu64, /* { dg-error "'PRIu64' undeclared" "undeclared identifier" { target *-*-* } } */
59 /* { dg-message "'PRIu64' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
60 PRIoPTR); /* { dg-error "'PRIoPTR' undeclared" "undeclared identifier" { target *-*-* } } */
61 /* { dg-message "'PRIoPTR' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
63 printf ("%" PRIo8 "\n", i8); /* { dg-error "expected" } */
64 /* { dg-message "'PRIo8' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
65 printf ("%" PRIo16 "\n", i16); /* { dg-error "expected" } */
66 /* { dg-message "'PRIo16' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
67 printf ("%" PRIo32 "\n", i32); /* { dg-error "expected" } */
68 /* { dg-message "'PRIo32' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
69 printf ("%" PRIo64 "\n", i64); /* { dg-error "expected" } */
70 /* { dg-message "'PRIo64' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
71 printf ("%" PRIoPTR "\n", ip); /* { dg-error "expected" } */
72 /* { dg-message "'PRIoPTR' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
75 void test_scanf (void)
77 scanf ("%" SCNu8 "\n", &i8); /* { dg-error "expected" } */
78 /* { dg-message "'SCNu8' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
79 scanf ("%" SCNu16 "\n", &i16); /* { dg-error "expected" } */
80 /* { dg-message "'SCNu16' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
81 scanf ("%" SCNu32 "\n", &i32); /* { dg-error "expected" } */
82 /* { dg-message "'SCNu32' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
83 scanf ("%" SCNu64 "\n", &i64); /* { dg-error "expected" } */
84 /* { dg-message "'SCNu64' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
85 scanf ("%" SCNuPTR "\n", &ip); /* { dg-error "expected" } */
86 /* { dg-message "'SCNuPTR' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */
87 scanf ("%" SCNxPTR "\n", &up); /* { dg-error "expected" } */
88 /* { dg-message "'SCNxPTR' is defined in header '<inttypes.h>'; this is probably fixable by adding '#include <inttypes.h>'" "replacement note" { target *-*-* } .-1 } */