Debian Codegraph @

gcc/testsuite/libgdiagnostics.dg/test-text-sink-options.c

raw
1 /* Example of controlling options for text sinks,
2 with multiple text sinks,
3 and color output. */
4
5 #include "libgdiagnostics.h"
6
7 /*
8 _________111111111122
9 123456789012345678901
10 PRINT "hello world!";
11 */
12 const int line_num = __LINE__ - 2;
13
14 int
15 main ()
16 {
17 diagnostic_manager *diag_mgr = diagnostic_manager_new ();
18
19 diagnostic_text_sink *sink_1
20 = diagnostic_manager_add_text_sink (diag_mgr, stderr,
21 DIAGNOSTIC_COLORIZE_NO);
22 diagnostic_text_sink_set_source_printing_enabled (sink_1, 0);
23
24 diagnostic_text_sink *sink_2
25 = diagnostic_manager_add_text_sink (diag_mgr, stderr,
26 DIAGNOSTIC_COLORIZE_YES);
27 diagnostic_text_sink_set_labelled_source_colorization_enabled (sink_2, 0);
28
29 const diagnostic_file *file = diagnostic_manager_new_file (diag_mgr, __FILE__, "c");
30 const diagnostic_physical_location *loc_start
31 = diagnostic_manager_new_location_from_file_line_column (diag_mgr, file, line_num, 8);
32 const diagnostic_physical_location *loc_end
33 = diagnostic_manager_new_location_from_file_line_column (diag_mgr, file, line_num, 19);
34 const diagnostic_physical_location *loc_range
35 = diagnostic_manager_new_location_from_range (diag_mgr,
36 loc_start,
37 loc_start,
38 loc_end);
39
40 diagnostic *d = diagnostic_begin (diag_mgr,
41 DIAGNOSTIC_LEVEL_ERROR);
42 diagnostic_set_location (d, loc_range);
43
44 diagnostic_finish (d, "can't find %qs", "foo");
45
46 diagnostic_manager_release (diag_mgr);
47 return 0;
48 };
49
50 /* Verify the output from text sink 1. */
51 /* { dg-regexp "\[^\n\r\]+test-text-sink-options.c:10:8: error: can't find 'foo'" } */
52
53 /* Verify the output from text sink 2.
54 { dg-regexp "\[^\n\r\]+test-text-sink-options.c:10:8:" }
55 { dg-begin-multiline-output "" }
56  error: can't find 'foo'
57 10 | PRINT "hello world!";
58 | ^~~~~~~~~~~~
59 { dg-end-multiline-output "" } */