PR tree-optimization/82929
[official-gcc.git] / gcc / selftest-diagnostic.c
blob201806288e41035da4b0b99756a66fdd28a7df7b
1 /* Selftest support for diagnostics.
2 Copyright (C) 2016-2017 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "diagnostic.h"
24 #include "selftest.h"
25 #include "selftest-diagnostic.h"
27 /* The selftest code should entirely disappear in a production
28 configuration, hence we guard all of it with #if CHECKING_P. */
30 #if CHECKING_P
32 namespace selftest {
34 /* Implementation of class selftest::test_diagnostic_context. */
36 test_diagnostic_context::test_diagnostic_context ()
38 diagnostic_initialize (this, 0);
39 show_caret = true;
40 show_column = true;
41 start_span = start_span_cb;
44 test_diagnostic_context::~test_diagnostic_context ()
46 diagnostic_finish (this);
49 /* Implementation of diagnostic_start_span_fn, hiding the
50 real filename (to avoid printing the names of tempfiles). */
52 void
53 test_diagnostic_context::start_span_cb (diagnostic_context *context,
54 expanded_location exploc)
56 exploc.file = "FILENAME";
57 default_diagnostic_start_span_fn (context, exploc);
60 } // namespace selftest
62 #endif /* #if CHECKING_P */