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)
14 myvar
= myvar
.x
; /* { dg-warning "test" } */
16 /* { dg-begin-multiline-output "" }
19 { dg-end-multiline-output "" } */
23 void test_multiline (void)
26 x
= (first_function ()
27 + second_function ()); /* { dg-warning "test" } */
29 /* { dg-begin-multiline-output "" }
30 26 | x = (first_function ()
32 27 | + second_function ());
33 | ^ ~~~~~~~~~~~~~~~~~~
36 { dg-end-multiline-output "" } */
40 void test_very_wide_line (void)
43 float f
= foo
* bar
; /* { dg-warning "95: test" } */
44 /* { dg-begin-multiline-output "" }
47 | 3456789012345678901234567890123456789012345678901234567890123456789012
48 43 | float f = foo * bar;
53 { dg-end-multiline-output "" } */
57 /* Unit test for rendering of insertion fixit hints
58 (example taken from PR 62316). */
60 void test_fixit_insert (void)
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 };
68 { dg-end-multiline-output "" } */
72 /* Unit test for rendering of "remove" fixit hints. */
74 void test_fixit_remove (void)
77 int a
;; /* { dg-warning "example of a removal hint" } */
78 /* { dg-begin-multiline-output "" }
82 { dg-end-multiline-output "" } */
86 /* Unit test for rendering of "replace" fixit hints. */
88 void test_fixit_replace (void)
91 gtk_widget_showall (dlg
); /* { dg-warning "example of a replacement hint" } */
92 /* { dg-begin-multiline-output "" }
93 91 | gtk_widget_showall (dlg);
96 { dg-end-multiline-output "" } */
101 /* Unit test for rendering of fix-it hints that add new lines. */
103 void test_fixit_insert_newline (void)
110 case 'b': /* { dg-warning "newline insertion" } */
113 /* { dg-begin-multiline-output "" }
118 { dg-end-multiline-output "" } */