111
|
1 /* { dg-do compile } */
|
|
2 /* { dg-options "-O -fdiagnostics-parseable-fixits" } */
|
|
3
|
|
4 /* This is a collection of unittests for diagnostic_show_locus;
|
|
5 see the overview in diagnostic_plugin_test_show_locus.c.
|
|
6
|
|
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. */
|
|
10
|
|
11 /* Unit test for rendering of insertion fixit hints
|
|
12 (example taken from PR 62316). */
|
|
13
|
|
14 void test_fixit_insert (void)
|
|
15 {
|
|
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
|
|
21 }
|
|
22
|
|
23 /* Unit test for rendering of "remove" fixit hints. */
|
|
24
|
|
25 void test_fixit_remove (void)
|
|
26 {
|
|
27 #if 0
|
|
28 int a;; /* { dg-warning "example of a removal hint" } */
|
|
29 /* { dg-regexp "fix-it:.*\\{28:9-28:10\\}:.*" } */
|
|
30 #endif
|
|
31 }
|
|
32
|
|
33 /* Unit test for rendering of "replace" fixit hints. */
|
|
34
|
|
35 void test_fixit_replace (void)
|
|
36 {
|
|
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
|
|
41 }
|
|
42
|
|
43 /* Unit test for rendering of fix-it hints that add new lines. */
|
|
44
|
|
45 void test_fixit_insert_newline (void)
|
|
46 {
|
|
47 #if 0
|
|
48 switch (op)
|
|
49 {
|
|
50 case 'a':
|
|
51 x = a;
|
|
52 case 'b': /* { dg-warning "newline insertion" } */
|
|
53 x = b;
|
|
54 }
|
|
55 /* { dg-regexp "fix-it:.*\\{52:1-52:1\\}:.*\\n" } */
|
|
56 #endif
|
|
57 }
|
|
58
|
|
59 /* Unit test for mutually-exclusive suggestions. */
|
|
60
|
|
61 void test_mutually_exclusive_suggestions (void)
|
|
62 {
|
|
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
|
|
71 }
|