aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/Wformat-gcc_diag-2.C
blob: 0cce53c9c36df0358de304ad98afb2a9d66ec8ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Test of -Wformat for subclasses of pp_element
// { dg-do compile }
// { dg-options "-Wformat" }

/* Magic identifiers must be set before the attribute is used.  */

typedef long long __gcc_host_wide_int__;

typedef struct location_s
{
  const char *file;
  int line;
} location_t;

union tree_node;
typedef union tree_node *tree;

/* Define gimple as a dummy type.  The typedef must be provided for
   the C test to find the symbol.  */
typedef struct gimple gimple;

/* Likewise for gimple.  */
typedef struct cgraph_node cgraph_node;

/* Likewise for diagnostic_event_id_t.  */
typedef struct diagnostic_event_id_t diagnostic_event_id_t;

namespace pp_markup {
class element
{
};
} // namespace pp_markup
typedef pp_markup::element pp_element;

#define FORMAT(kind) __attribute__ ((format (__gcc_## kind ##__, 1, 2)))

void diag (const char*, ...) FORMAT (diag);

class sub_element : public pp_element
{
};

class sub_sub_element : public sub_element
{
};

void test_diag ()
{
  sub_element e1;
  sub_sub_element e2;
  diag ("%e %e", &e1, &e2);
}