Fortran: Fix PR 47485.
[gcc.git] / gcc / testsuite / g++.dg / warn / Wformat-gcc_diag-3.C
blobf474778398ef08e057c85de95fd803e1d7c4deb0
1 // Test of -Wformat for subclasses of pp_element
2 // { dg-do compile }
3 // { dg-options "-Wformat" }
5 union tree_node;
6 typedef union tree_node *tree;
7 class rich_location;
8 class pretty_printer;
10 namespace pp_markup {
11 class element {};
13 } // namespace pp_markup
15 typedef pp_markup::element pp_element;
17 extern void error_at (rich_location *, const char *, ...)
18   __attribute__ ((__format__ (__gcc_cdiag__, 2, 3),
19                   __nonnull__ (2)));
21 namespace highlight_colors {
23 extern const char *const lhs;
24 extern const char *const rhs;
26 } // namespace highlight_colors
28 namespace pp_markup {
30 class element_quoted_type : public element
32 public:
33   element_quoted_type (tree type, const char *highlight_color)
34   : m_type (type),
35     m_highlight_color (highlight_color)
36   {
37   }
38 private:
39   tree m_type;
40   const char *m_highlight_color;
45 void
46 binary_op_error (rich_location *richloc, const char *opname,
47                  tree type0, tree type1)
49   pp_markup::element_quoted_type element_0 (type0, highlight_colors::lhs);
50   pp_markup::element_quoted_type element_1 (type1, highlight_colors::rhs);
51   error_at (richloc,
52             "invalid operands to binary %s (have %e and %e)",
53             opname, &element_0, &element_1);