Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / diagnostic-test-show-locus-bw-line-numbers.c
blob1e8f73bdb5d92763b7c74864a6696767291b02b0
1 /* { dg-do compile } */
2 /* { dg-options "-O -fdiagnostics-show-caret -fdiagnostics-show-line-numbers" } */
4 /* This is a collection of unittests for diagnostic_show_locus;
5 see the overview in diagnostic_plugin_test_show_locus.c.
7 In particular, note the discussion of why we need a very long line here:
8 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
9 and that we can't use macros in this file. */
11 void test_simple (void)
13 #if 0
14 myvar = myvar.x; /* { dg-warning "test" } */
16 /* { dg-begin-multiline-output "" }
17 14 | myvar = myvar.x;
18 | ~~~~~^~
19 { dg-end-multiline-output "" } */
20 #endif
23 void test_multiline (void)
25 #if 0
26 x = (first_function ()
27 + second_function ()); /* { dg-warning "test" } */
29 /* { dg-begin-multiline-output "" }
30 26 | x = (first_function ()
31 | ~~~~~~~~~~~~~~~~~
32 27 | + second_function ());
33 | ^ ~~~~~~~~~~~~~~~~~~
34 | |
35 | label
36 { dg-end-multiline-output "" } */
37 #endif
40 void test_very_wide_line (void)
42 #if 0
43 float f = foo * bar; /* { dg-warning "95: test" } */
44 /* { dg-begin-multiline-output "" }
45 | 0 0 0 0 0 1 1
46 | 5 6 7 8 9 0 1
47 | 3456789012345678901234567890123456789012345678901234567890123456789012
48 43 | float f = foo * bar;
49 | ~~~~^~~~~
50 | |
51 | label 0
52 | bar * foo
53 { dg-end-multiline-output "" } */
54 #endif
57 /* Unit test for rendering of insertion fixit hints
58 (example taken from PR 62316). */
60 void test_fixit_insert (void)
62 #if 0
63 int a[2][2] = { 0, 1 , 2, 3 }; /* { dg-warning "insertion hints" } */
64 /* { dg-begin-multiline-output "" }
65 63 | int a[2][2] = { 0, 1 , 2, 3 };
66 | ^~~~
67 | { }
68 { dg-end-multiline-output "" } */
69 #endif
72 /* Unit test for rendering of "remove" fixit hints. */
74 void test_fixit_remove (void)
76 #if 0
77 int a;; /* { dg-warning "example of a removal hint" } */
78 /* { dg-begin-multiline-output "" }
79 77 | int a;;
80 | ^
81 | -
82 { dg-end-multiline-output "" } */
83 #endif
86 /* Unit test for rendering of "replace" fixit hints. */
88 void test_fixit_replace (void)
90 #if 0
91 gtk_widget_showall (dlg); /* { dg-warning "example of a replacement hint" } */
92 /* { dg-begin-multiline-output "" }
93 91 | gtk_widget_showall (dlg);
94 | ^~~~~~~~~~~~~~~~~~
95 | gtk_widget_show_all
96 { dg-end-multiline-output "" } */
97 #endif
101 /* Unit test for rendering of fix-it hints that add new lines. */
103 void test_fixit_insert_newline (void)
105 #if 0
106 switch (op)
108 case 'a':
109 x = a;
110 case 'b': /* { dg-warning "newline insertion" } */
111 x = b;
113 /* { dg-begin-multiline-output "" }
114 109 | x = a;
115 +++ |+ break;
116 110 | case 'b':
117 | ^~~~~~~~
118 { dg-end-multiline-output "" } */
119 #endif