1 /* Similar to diagnostic-test-string-literals-1.c, but with
2    -ftrack-macro-expansion=0.  */
3 
4 /* { dg-do compile } */
5 /* { dg-options "-O -ftrack-macro-expansion=0" } */
6 
7 extern void __emit_string_literal_range (const void *literal, int caret_idx,
8 					 int start_idx, int end_idx);
9 
10 void
test_simple_string_literal(void)11 test_simple_string_literal (void)
12 {
13   __emit_string_literal_range ("0123456789", /* { dg-error "unable to read substring location: track_macro_expansion != 2" } */
14 			       6, 6, 7);
15 }
16 
17 void
test_concatenated_string_literal(void)18 test_concatenated_string_literal (void)
19 {
20   __emit_string_literal_range ("01234" "56789", /* { dg-error "unable to read substring location: track_macro_expansion != 2" } */
21 			       4, 3, 6);
22 }
23 
24 /* To reproduce PR preprocessor/78324, the macro name should start
25    with the letter 'R'.  */
26 
27 void
test_macro(void)28 test_macro (void)
29 {
30 #define RANGE "01234"
31   __emit_string_literal_range (RANGE /* { dg-error "unable to read substring location: track_macro_expansion != 2" } */
32                                "56789",
33                                4, 3, 6);
34 #undef RANGE
35 }
36 
37 void
test_multitoken_macro(void)38 test_multitoken_macro (void)
39 {
40 #define RANGE ("0123456789")
41   __emit_string_literal_range (RANGE, 4, 3, 6); /* { dg-error "unable to read substring location: track_macro_expansion != 2" } */
42 #undef RANGE
43 }
44