Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / diagnostic-test-string-literals-2.c
blobe9d98f4d6befc90b2b179a141c2a2eb535600aa9
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. */
10 void
11 test_stringified_token_1 (int x)
13 #define STRINGIFY(EXPR) #EXPR
15 __emit_string_literal_range (STRINGIFY(x > 0), /* { dg-error "unable to read substring location: macro expansion" } */
16 0, 0, 4);
18 #undef STRINGIFY
21 /* Test of a stringified token within a concatenation. */
23 void
24 test_stringized_token_2 (int x)
26 #define EXAMPLE(EXPR, CARET_IDX, START_IDX, END_IDX) \
27 do { \
28 __emit_string_literal_range (" before " #EXPR " after \n", \
29 CARET_IDX, START_IDX, END_IDX); \
30 } while (0)
32 EXAMPLE(x > 0, 1, 1, 6);
33 /* { dg-error "unable to read substring location: cpp_interpret_string_1 failed" "" { target *-*-* } .-5 } */
35 #undef EXAMPLE
38 /* Test of a doubly-stringified macro argument (by itself). */
40 void
41 test_stringified_token_3 (int x)
43 #define XSTR(s) STR(s)
44 #define STR(s) #s
45 #define FOO 123456789
46 __emit_string_literal_range (XSTR (FOO), /* { dg-error "unable to read substring location: macro expansion" } */
47 2, 2, 3);
49 #undef XSTR
50 #undef STR
51 #undef FOO
54 /* Test of a stringified macro argument within a concatenation. */
56 void
57 test_pr79210 (void)
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 "
70 "here");
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