1 /* { dg-do compile } */
2 /* { dg-options "-O" } */
3 /* { dg-set-compiler-env-var GCC_EXTRA_DIAGNOSTIC_OUTPUT "fixits-v2" }
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 /* Unit test for rendering of insertion fixit hints
12 (example taken from PR 62316). */
14 void test_fixit_insert (void)
17 int a
[2][2] = { 0, 1 , 2, 3 }; /* { dg-warning "insertion hints" } */
18 /* { dg-regexp "fix-it:.*\\{17:20-17:20\\}:.*" } */
19 /* { dg-regexp "fix-it:.*\\{17:24-17:24\\}:.*" } */
23 /* Unit test for rendering of "remove" fixit hints. */
25 void test_fixit_remove (void)
28 int a
;; /* { dg-warning "example of a removal hint" } */
29 /* { dg-regexp "fix-it:.*\\{28:9-28:10\\}:.*" } */
33 /* Unit test for rendering of "replace" fixit hints. */
35 void test_fixit_replace (void)
38 gtk_widget_showall (dlg
); /* { dg-warning "example of a replacement hint" } */
39 /* { dg-regexp "fix-it:.*\\{38:3-38:21\\}:.*" } */
43 /* Unit test for rendering of fix-it hints that add new lines. */
45 void test_fixit_insert_newline (void)
52 case 'b': /* { dg-warning "newline insertion" } */
55 /* { dg-regexp "fix-it:.*\\{52:1-52:1\\}:.*\\n" } */
59 /* Unit test for mutually-exclusive suggestions. */
61 void test_mutually_exclusive_suggestions (void)
64 original
; /* { dg-warning "warning 1" } */
65 /* { dg-warning "warning 2" "" { target *-*-* } .-1 } */
66 /* We should print the mutually-incompatible fix-it hints within
67 -fdiagnostics-parseable-fixits; verify that they are printed. */
68 /* { dg-regexp "fix-it:.*\\{64:3-64:11}:.*\\n" } */
69 /* { dg-regexp "fix-it:.*\\{64:3-64:11}:.*\\n" } */