| 1 |
// Test of -Wformat for subclasses of pp_element |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-Wformat" } |
| 4 |
|
| 5 |
union tree_node; |
| 6 |
typedef union tree_node *tree; |
| 7 |
class rich_location; |
| 8 |
class pretty_printer; |
| 9 |
|
| 10 |
namespace pp_markup { |
| 11 |
class element {}; |
| 12 |
|
| 13 |
} // namespace pp_markup |
| 14 |
|
| 15 |
typedef pp_markup::element pp_element; |
| 16 |
|
| 17 |
extern void error_at (rich_location *, const char *, ...) |
| 18 |
__attribute__ ((__format__ (__gcc_cdiag__, 2, 3), |
| 19 |
__nonnull__ (2))); |
| 20 |
|
| 21 |
namespace highlight_colors { |
| 22 |
|
| 23 |
extern const char *const lhs; |
| 24 |
extern const char *const rhs; |
| 25 |
|
| 26 |
} // namespace highlight_colors |
| 27 |
|
| 28 |
namespace pp_markup { |
| 29 |
|
| 30 |
class element_quoted_type : public element |
| 31 |
{ |
| 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; |
| 41 |
}; |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
void |
| 46 |
binary_op_error (rich_location *richloc, const char *opname, |
| 47 |
tree type0, tree type1) |
| 48 |
{ |
| 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); |
| 54 |
} |