Add support for mutually-incompatible fix-it hints
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / diagnostic-test-show-locus-generate-patch.c
blobf1963dd20c1e3a8925461f3eb81f62fc23b5ea1d
1 /* { dg-do compile } */
2 /* { dg-options "-O -fdiagnostics-generate-patch" } */
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 #endif
21 /* Unit test for rendering of "remove" fixit hints. */
23 void test_fixit_remove (void)
25 #if 0
26 int a;; /* { dg-warning "example of a removal hint" } */
27 #endif
30 /* Unit test for rendering of "replace" fixit hints. */
32 void test_fixit_replace (void)
34 #if 0
35 gtk_widget_showall (dlg); /* { dg-warning "example of a replacement hint" } */
36 #endif
39 /* Unit test for rendering of fix-it hints that add new lines. */
41 void test_fixit_insert_newline (void)
43 #if 0
44 switch (op)
46 case 'a':
47 x = a;
48 case 'b': /* { dg-warning "newline insertion" } */
49 x = b;
51 #endif
54 /* Unit test for mutually-exclusive suggestions. */
56 void test_mutually_exclusive_suggestions (void)
58 #if 0
59 original; /* { dg-warning "warning 1" } */
60 /* { dg-warning "warning 2" "" { target *-*-* } .-1 } */
61 /* We should not print the mutually-incompatible fix-it hints within
62 the generated patch; they are not listed in the big expected
63 multiline output below. */
64 #endif
67 /* Verify the output from -fdiagnostics-generate-patch.
68 We expect a header, containing the filename. This is the absolute path,
69 so we can only capture it via regexps. */
71 /* { dg-regexp "\\-\\-\\- .*" } */
72 /* { dg-regexp "\\+\\+\\+ .*" } */
74 /* Next, we expect the diff itself. */
75 /* { dg-begin-multiline-output "" }
76 @@ -14,7 +14,7 @@
77 void test_fixit_insert (void)
79 #if 0
80 - int a[2][2] = { 0, 1 , 2, 3 };
81 + int a[2][2] = { {0, 1} , 2, 3 };
82 #endif
85 @@ -23,7 +23,7 @@
86 void test_fixit_remove (void)
88 #if 0
89 - int a;;
90 + int a;
91 #endif
94 @@ -32,7 +32,7 @@
95 void test_fixit_replace (void)
97 #if 0
98 - gtk_widget_showall (dlg);
99 + gtk_widget_show_all (dlg);
100 #endif
103 @@ -45,6 +45,7 @@
105 case 'a':
106 x = a;
107 + break;
108 case 'b':
109 x = b;
111 { dg-end-multiline-output "" } */