Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / diagnostic-test-show-locus-color.c
blob094bc6535d5e4c9748c815bea1facef81eba0902
1 /* { dg-do compile } */
2 /* { dg-options "-O -fdiagnostics-show-caret -fplugin-arg-diagnostic_plugin_test_show_locus-color" } */
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 myvar = \e[32m\e[Kmyvar\e[m\e[K\e[01;35m\e[K.\e[m\e[K\e[34m\e[Kx\e[m\e[K;
18 \e[32m\e[K~~~~~\e[m\e[K\e[01;35m\e[K^\e[m\e[K\e[34m\e[K~\e[m\e[K
19 { dg-end-multiline-output "" } */
20 #endif
23 void test_simple_2 (void)
25 #if 0
26 x = first_function () + second_function (); /* { dg-warning "test" } */
28 /* { dg-begin-multiline-output "" }
29 x = \e[32m\e[Kfirst_function ()\e[m\e[K \e[01;35m\e[K+\e[m\e[K \e[34m\e[Ksecond_function ()\e[m\e[K;
30 \e[32m\e[K~~~~~~~~~~~~~~~~~\e[m\e[K \e[01;35m\e[K^\e[m\e[K \e[34m\e[K~~~~~~~~~~~~~~~~~~\e[m\e[K
31 { dg-end-multiline-output "" } */
32 #endif
36 void test_multiline (void)
38 #if 0
39 x = (first_function ()
40 + second_function ()); /* { dg-warning "test" } */
42 /* { dg-begin-multiline-output "" }
43 x = (\e[32m\e[Kfirst_function ()\e[m\e[K
44 \e[32m\e[K~~~~~~~~~~~~~~~~~\e[m\e[K
45 \e[01;35m\e[K+\e[m\e[K \e[34m\e[Ksecond_function ()\e[m\e[K);
46 \e[01;35m\e[K^\e[m\e[K \e[34m\e[K~~~~~~~~~~~~~~~~~~\e[m\e[K
47 \e[01;35m\e[K|\e[m\e[K
48 \e[01;35m\e[Klabel\e[m\e[K
49 { dg-end-multiline-output "" } */
50 #endif
53 void test_many_lines (void)
55 #if 0
56 x = (first_function_with_a_very_long_name (lorem, ipsum, dolor, sit, amet,
57 consectetur, adipiscing, elit,
58 sed, eiusmod, tempor,
59 incididunt, ut, labore, et,
60 dolore, magna, aliqua)
61 + second_function_with_a_very_long_name (lorem, ipsum, dolor, sit, /* { dg-warning "test" } */
62 amet, consectetur,
63 adipiscing, elit, sed,
64 eiusmod, tempor, incididunt,
65 ut, labore, et, dolore,
66 magna, aliqua));
68 /* { dg-begin-multiline-output "" }
69 x = (\e[32m\e[Kfirst_function_with_a_very_long_name (lorem, ipsum, dolor, sit, amet,\e[m\e[K
70 \e[32m\e[K~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\e[m\e[K
71 \e[32m\e[K|\e[m\e[K
72 \e[32m\e[Klabel 1\e[m\e[K
73 \e[32m\e[K consectetur, adipiscing, elit,\e[m\e[K
74 \e[32m\e[K~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\e[m\e[K
75 \e[32m\e[K sed, eiusmod, tempor,\e[m\e[K
76 \e[32m\e[K~~~~~~~~~~~~~~~~~~~~~\e[m\e[K
77 \e[32m\e[K incididunt, ut, labore, et,\e[m\e[K
78 \e[32m\e[K~~~~~~~~~~~~~~~~~~~~~~~~~~~\e[m\e[K
79 \e[32m\e[K dolore, magna, aliqua)\e[m\e[K
80 \e[32m\e[K~~~~~~~~~~~~~~~~~~~~~~\e[m\e[K
81 \e[01;35m\e[K+\e[m\e[K \e[34m\e[Ksecond_function_with_a_very_long_name (lorem, ipsum, dolor, sit,
82 \e[01;35m\e[K^\e[m\e[K \e[34m\e[K~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\e[m\e[K
83 \e[01;35m\e[K|\e[m\e[K \e[34m\e[K|\e[m\e[K
84 \e[01;35m\e[K|\e[m\e[K \e[34m\e[Klabel 2\e[m\e[K
85 \e[01;35m\e[Klabel 0\e[m\e[K
86 \e[34m\e[K amet, consectetur,\e[m\e[K
87 \e[34m\e[K~~~~~~~~~~~~~~~~~~\e[m\e[K
88 \e[34m\e[K adipiscing, elit, sed,\e[m\e[K
89 \e[34m\e[K~~~~~~~~~~~~~~~~~~~~~~\e[m\e[K
90 \e[34m\e[K eiusmod, tempor, incididunt,\e[m\e[K
91 \e[34m\e[K~~~~~~~~~~~~~~~~~~~~~~~~~~~~\e[m\e[K
92 \e[34m\e[K ut, labore, et, dolore,\e[m\e[K
93 \e[34m\e[K~~~~~~~~~~~~~~~~~~~~~~~\e[m\e[K
94 \e[34m\e[K magna, aliqua)\e[m\e[K);
95 \e[34m\e[K~~~~~~~~~~~~~~\e[m\e[K
96 { dg-end-multiline-output "" } */
97 #endif
100 void test_richloc_from_proper_range (void)
102 #if 0
103 float f = 98.6f; /* { dg-warning "test" } */
104 /* { dg-begin-multiline-output "" }
105 float f = \e[01;35m\e[K98.6f\e[m\e[K;
106 \e[01;35m\e[K^~~~~\e[m\e[K
107 { dg-end-multiline-output "" } */
108 #endif
111 void test_caret_within_proper_range (void)
113 #if 0
114 float f = foo * bar; /* { dg-warning "17: test" } */
115 /* { dg-begin-multiline-output "" }
116 float f = \e[01;35m\e[Kfoo * bar\e[m\e[K;
117 \e[01;35m\e[K~~~~^~~~~\e[m\e[K
118 { dg-end-multiline-output "" } */
119 #endif
122 void test_very_wide_line (void)
124 #if 0
125 float x = foo * bar; /* { dg-warning "95: test" } */
126 /* { dg-begin-multiline-output "" }
127 0 0 0 0 0 0 1
128 4 5 6 7 8 9 0
129 6789012345678901234567890123456789012345678901234567890123456789012345
130 \e[32m\e[Kx\e[m\e[K = \e[01;35m\e[Kfoo * bar\e[m\e[K;
131 \e[32m\e[K~\e[m\e[K \e[01;35m\e[K~~~~^~~~~\e[m\e[K
132 \e[32m\e[K|\e[m\e[K \e[01;35m\e[K|\e[m\e[K
133 \e[32m\e[Klabel 1\e[m\e[K \e[01;35m\e[Klabel 0\e[m\e[K
134 \e[32m\e[Kbar * foo\e[m\e[K
135 { dg-end-multiline-output "" } */
136 #endif
139 void test_multiple_carets (void)
141 #if 0
142 x = x + y /* { dg-warning "8: test" } */
143 /* { dg-begin-multiline-output "" }
144 x = \e[01;35m\e[Kx\e[m\e[K + \e[32m\e[Ky\e[m\e[K
145 \e[01;35m\e[KA\e[m\e[K \e[32m\e[KB\e[m\e[K
146 { dg-end-multiline-output "" } */
147 #endif
150 void test_caret_on_leading_whitespace (void)
152 #if 0
153 ASSOCIATE (y => x)
154 y = 5 /* { dg-warning "6: test" } */
155 /* { dg-begin-multiline-output "" }
156 ASSOCIATE (y =>\e[32m\e[K \e[m\e[Kx)
157 \e[32m\e[K2\e[m\e[K
158 \e[01;35m\e[K \e[m\e[Ky = 5
159 \e[01;35m\e[K1\e[m\e[K
160 { dg-end-multiline-output "" } */
161 #endif
164 /* Unit test for rendering of insertion fixit hints
165 (example taken from PR 62316). */
167 void test_fixit_insert (void)
169 #if 0
170 int a[2][2] = { 0, 1 , 2, 3 }; /* { dg-warning "insertion hints" } */
171 /* { dg-begin-multiline-output "" }
172 int a[2][2] = { \e[01;35m\e[K0, 1\e[m\e[K , 2, 3 };
173 \e[01;35m\e[K^~~~\e[m\e[K
174 \e[32m\e[K{\e[m\e[K \e[32m\e[K}\e[m\e[K
175 { dg-end-multiline-output "" } */
176 #endif
179 /* Unit test for rendering of "remove" fixit hints. */
181 void test_fixit_remove (void)
183 #if 0
184 int a;; /* { dg-warning "example of a removal hint" } */
185 /* { dg-begin-multiline-output "" }
186 int a;\e[01;35m\e[K;\e[m\e[K
187 \e[01;35m\e[K^\e[m\e[K
188 \e[31m\e[K-\e[m\e[K
189 { dg-end-multiline-output "" } */
190 #endif
193 /* Unit test for rendering of "replace" fixit hints. */
195 void test_fixit_replace (void)
197 #if 0
198 gtk_widget_showall (dlg); /* { dg-warning "example of a replacement hint" } */
199 /* { dg-begin-multiline-output "" }
200 \e[01;35m\e[Kgtk_widget_showall\e[m\e[K (dlg);
201 \e[01;35m\e[K^~~~~~~~~~~~~~~~~~\e[m\e[K
202 \e[32m\e[Kgtk_widget_show_all\e[m\e[K
203 { dg-end-multiline-output "" } */
204 #endif
207 /* Unit test for rendering of fix-it hints that add new lines. */
209 void test_fixit_insert_newline (void)
211 #if 0
212 switch (op)
214 case 'a':
215 x = a;
216 case 'b': /* { dg-warning "newline insertion" } */
217 x = b;
219 /* { dg-begin-multiline-output "" }
220 +\e[32m\e[K break;\e[m\e[K
221 \e[01;35m\e[Kcase 'b'\e[m\e[K:
222 \e[01;35m\e[K^~~~~~~~\e[m\e[K
223 { dg-end-multiline-output "" } */
224 #endif