Debian Codegraph @

gcc/testsuite/libgdiagnostics.dg/test-example-1.c

raw
1 /* begin quoted source */
2 /* Minimal usage example. */
3 #include "libgdiagnostics.h"
4
5 static diagnostic_manager *diag_mgr;
6
7 static void
8 init_diagnostics (void)
9 {
10 diag_mgr = diagnostic_manager_new ();
11 diagnostic_manager_add_text_sink (diag_mgr, stderr,
12 DIAGNOSTIC_COLORIZE_IF_TTY);
13 }
14
15 static void
16 finish_diagnostics (void)
17 {
18 diagnostic_manager_release (diag_mgr);
19 }
20
21 static void
22 do_stuff (void)
23 {
24 const char *username = "Dave";
25 diagnostic *d = diagnostic_begin (diag_mgr,
26 DIAGNOSTIC_LEVEL_ERROR);
27 diagnostic_finish (d,
28 "I'm sorry %s, I'm afraid I can't do that",
29 username);
30 }
31
32 int
33 main ()
34 {
35 init_diagnostics ();
36
37 do_stuff ();
38
39 finish_diagnostics ();
40 };
41 /* end quoted source */
42
43 /* { dg-regexp "progname: error: I'm sorry Dave, I'm afraid I can't do that" } */