1 /* { dg-do compile } */
3 /* See the notes in diagnostic-test-string-literals-1.c.
4 This test case has caret-printing disabled. */
6 extern void __emit_string_literal_range (const void *literal
, int caret_idx
,
7 int start_idx
, int end_idx
);
8 /* Test of a stringified macro argument, by itself. */
11 test_stringified_token_1 (int x
)
13 #define STRINGIFY(EXPR) #EXPR
15 __emit_string_literal_range (STRINGIFY(x
> 0), /* { dg-error "macro expansion|cpp_interpret_string_1 failed" } */
21 /* Test of a stringified token within a concatenation. */
24 test_stringized_token_2 (int x
)
26 #define EXAMPLE(EXPR, CARET_IDX, START_IDX, END_IDX) \
28 __emit_string_literal_range (" before " #EXPR " after \n", \
29 CARET_IDX, START_IDX, END_IDX); \
32 EXAMPLE(x
> 0, 1, 1, 6);
33 /* { dg-error "unable to read substring location: cpp_interpret_string_1 failed" "" { target *-*-* } .-5 } */
38 /* Test of a doubly-stringified macro argument (by itself). */
41 test_stringified_token_3 (int x
)
43 #define XSTR(s) STR(s)
46 __emit_string_literal_range (XSTR (FOO
), /* { dg-error "macro expansion|cpp_interpret_string_1 failed" } */
54 /* Test of a stringified macro argument within a concatenation. */
59 #define lpfc_vport_param_init(attr) \
60 __emit_string_literal_range ( \
61 "0423 lpfc_"#attr" attribute cannot be set to %d, "\
62 "allowed range is [0, 1]\n", 54, 53, 54) \
64 #define LPFC_VPORT_ATTR_R(name, decc) \
65 unsigned int lpfc_##name; \
66 lpfc_vport_param_init(name) \
68 LPFC_VPORT_ATTR_R(peer_port_login,
69 "some multiline blurb with a short final line "
72 /* { dg-error "19: unable to read substring location: line is not wide enough" "" { target *-*-* } .-11 } */
74 #undef LPFC_VPORT_ATTR_R
75 #undef lpfc_vport_param_init