Add support for mutually-incompatible fix-it hints
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / diagnostic-test-show-locus-parseable-fixits.c
blob16162baeb7ec60cecd093f1508477e3ec0418842
1 /* { dg-do compile } */
2 /* { dg-options "-O -fdiagnostics-parseable-fixits" } */
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)
16 #if 0
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\\}:.*" } */
20 #endif
23 /* Unit test for rendering of "remove" fixit hints. */
25 void test_fixit_remove (void)
27 #if 0
28 int a;; /* { dg-warning "example of a removal hint" } */
29 /* { dg-regexp "fix-it:.*\\{28:9-28:10\\}:.*" } */
30 #endif
33 /* Unit test for rendering of "replace" fixit hints. */
35 void test_fixit_replace (void)
37 #if 0
38 gtk_widget_showall (dlg); /* { dg-warning "example of a replacement hint" } */
39 /* { dg-regexp "fix-it:.*\\{38:3-38:21\\}:.*" } */
40 #endif
43 /* Unit test for rendering of fix-it hints that add new lines. */
45 void test_fixit_insert_newline (void)
47 #if 0
48 switch (op)
50 case 'a':
51 x = a;
52 case 'b': /* { dg-warning "newline insertion" } */
53 x = b;
55 /* { dg-regexp "fix-it:.*\\{52:1-52:1\\}:.*\\n" } */
56 #endif
59 /* Unit test for mutually-exclusive suggestions. */
61 void test_mutually_exclusive_suggestions (void)
63 #if 0
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" } */
70 #endif