annotate gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* { dg-do compile } */
kono
parents:
diff changeset
2 /* { dg-options "-O -fdiagnostics-generate-patch" } */
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 /* This is a collection of unittests for diagnostic_show_locus;
kono
parents:
diff changeset
5 see the overview in diagnostic_plugin_test_show_locus.c.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 In particular, note the discussion of why we need a very long line here:
kono
parents:
diff changeset
8 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
kono
parents:
diff changeset
9 and that we can't use macros in this file. */
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 /* Unit test for rendering of insertion fixit hints
kono
parents:
diff changeset
12 (example taken from PR 62316). */
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 void test_fixit_insert (void)
kono
parents:
diff changeset
15 {
kono
parents:
diff changeset
16 #if 0
kono
parents:
diff changeset
17 int a[2][2] = { 0, 1 , 2, 3 }; /* { dg-warning "insertion hints" } */
kono
parents:
diff changeset
18 #endif
kono
parents:
diff changeset
19 }
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 /* Unit test for rendering of "remove" fixit hints. */
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 void test_fixit_remove (void)
kono
parents:
diff changeset
24 {
kono
parents:
diff changeset
25 #if 0
kono
parents:
diff changeset
26 int a;; /* { dg-warning "example of a removal hint" } */
kono
parents:
diff changeset
27 #endif
kono
parents:
diff changeset
28 }
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 /* Unit test for rendering of "replace" fixit hints. */
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 void test_fixit_replace (void)
kono
parents:
diff changeset
33 {
kono
parents:
diff changeset
34 #if 0
kono
parents:
diff changeset
35 gtk_widget_showall (dlg); /* { dg-warning "example of a replacement hint" } */
kono
parents:
diff changeset
36 #endif
kono
parents:
diff changeset
37 }
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 /* Unit test for rendering of fix-it hints that add new lines. */
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 void test_fixit_insert_newline (void)
kono
parents:
diff changeset
42 {
kono
parents:
diff changeset
43 #if 0
kono
parents:
diff changeset
44 switch (op)
kono
parents:
diff changeset
45 {
kono
parents:
diff changeset
46 case 'a':
kono
parents:
diff changeset
47 x = a;
kono
parents:
diff changeset
48 case 'b': /* { dg-warning "newline insertion" } */
kono
parents:
diff changeset
49 x = b;
kono
parents:
diff changeset
50 }
kono
parents:
diff changeset
51 #endif
kono
parents:
diff changeset
52 }
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 /* Unit test for mutually-exclusive suggestions. */
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 void test_mutually_exclusive_suggestions (void)
kono
parents:
diff changeset
57 {
kono
parents:
diff changeset
58 #if 0
kono
parents:
diff changeset
59 original; /* { dg-warning "warning 1" } */
kono
parents:
diff changeset
60 /* { dg-warning "warning 2" "" { target *-*-* } .-1 } */
kono
parents:
diff changeset
61 /* We should not print the mutually-incompatible fix-it hints within
kono
parents:
diff changeset
62 the generated patch; they are not listed in the big expected
kono
parents:
diff changeset
63 multiline output below. */
kono
parents:
diff changeset
64 #endif
kono
parents:
diff changeset
65 }
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 /* Verify the output from -fdiagnostics-generate-patch.
kono
parents:
diff changeset
68 We expect a header, containing the filename. This is the absolute path,
kono
parents:
diff changeset
69 so we can only capture it via regexps. */
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 /* { dg-regexp "\\-\\-\\- .*" } */
kono
parents:
diff changeset
72 /* { dg-regexp "\\+\\+\\+ .*" } */
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 /* Next, we expect the diff itself. */
kono
parents:
diff changeset
75 /* { dg-begin-multiline-output "" }
kono
parents:
diff changeset
76 @@ -14,7 +14,7 @@
kono
parents:
diff changeset
77 void test_fixit_insert (void)
kono
parents:
diff changeset
78 {
kono
parents:
diff changeset
79 #if 0
kono
parents:
diff changeset
80 - int a[2][2] = { 0, 1 , 2, 3 };
kono
parents:
diff changeset
81 + int a[2][2] = { {0, 1} , 2, 3 };
kono
parents:
diff changeset
82 #endif
kono
parents:
diff changeset
83 }
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 @@ -23,7 +23,7 @@
kono
parents:
diff changeset
86 void test_fixit_remove (void)
kono
parents:
diff changeset
87 {
kono
parents:
diff changeset
88 #if 0
kono
parents:
diff changeset
89 - int a;;
kono
parents:
diff changeset
90 + int a;
kono
parents:
diff changeset
91 #endif
kono
parents:
diff changeset
92 }
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 @@ -32,7 +32,7 @@
kono
parents:
diff changeset
95 void test_fixit_replace (void)
kono
parents:
diff changeset
96 {
kono
parents:
diff changeset
97 #if 0
kono
parents:
diff changeset
98 - gtk_widget_showall (dlg);
kono
parents:
diff changeset
99 + gtk_widget_show_all (dlg);
kono
parents:
diff changeset
100 #endif
kono
parents:
diff changeset
101 }
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 @@ -45,6 +45,7 @@
kono
parents:
diff changeset
104 {
kono
parents:
diff changeset
105 case 'a':
kono
parents:
diff changeset
106 x = a;
kono
parents:
diff changeset
107 + break;
kono
parents:
diff changeset
108 case 'b':
kono
parents:
diff changeset
109 x = b;
kono
parents:
diff changeset
110 }
kono
parents:
diff changeset
111 { dg-end-multiline-output "" } */