Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-2.C

raw
1 // Test of -Wformat for subclasses of pp_element
2 // { dg-do compile }
3 // { dg-options "-Wformat" }
4
5 /* Magic identifiers must be set before the attribute is used. */
6
7 typedef long long __gcc_host_wide_int__;
8
9 typedef struct location_s
10 {
11 const char *file;
12 int line;
13 } location_t;
14
15 union tree_node;
16 typedef union tree_node *tree;
17
18 /* Define gimple as a dummy type. The typedef must be provided for
19 the C test to find the symbol. */
20 typedef struct gimple gimple;
21
22 /* Likewise for gimple. */
23 typedef struct cgraph_node cgraph_node;
24
25 /* Likewise for diagnostic_event_id_t. */
26 typedef struct diagnostic_event_id_t diagnostic_event_id_t;
27
28 namespace pp_markup {
29 class element
30 {
31 };
32 } // namespace pp_markup
33 typedef pp_markup::element pp_element;
34
35 #define FORMAT(kind) __attribute__ ((format (__gcc_## kind ##__, 1, 2)))
36
37 void diag (const char*, ...) FORMAT (diag);
38
39 class sub_element : public pp_element
40 {
41 };
42
43 class sub_sub_element : public sub_element
44 {
45 };
46
47 void test_diag ()
48 {
49 sub_element e1;
50 sub_sub_element e2;
51 diag ("%e %e", &e1, &e2);
52 }