gcc80: Handle TZ specific "%+" format in strftime.
[dragonfly.git] / contrib / gcc-8.0 / gcc / gcc-rich-location.c
1 /* Implementation of gcc_rich_location class
2    Copyright (C) 2014-2018 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
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.
10
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.
15
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/>.  */
19
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "tm.h"
24 #include "rtl.h"
25 #include "hash-set.h"
26 #include "vec.h"
27 #include "input.h"
28 #include "alias.h"
29 #include "symtab.h"
30 #include "inchash.h"
31 #include "tree-core.h"
32 #include "tree.h"
33 #include "diagnostic-core.h"
34 #include "gcc-rich-location.h"
35 #include "print-tree.h"
36 #include "pretty-print.h"
37 #include "intl.h"
38 #include "cpplib.h"
39 #include "diagnostic.h"
40
41 /* Add a range to the rich_location, covering expression EXPR. */
42
43 void
44 gcc_rich_location::add_expr (tree expr)
45 {
46   gcc_assert (expr);
47
48   if (CAN_HAVE_RANGE_P (expr))
49     add_range (EXPR_LOCATION (expr), false);
50 }
51
52 /* If T is an expression, add a range for it to the rich_location.  */
53
54 void
55 gcc_rich_location::maybe_add_expr (tree t)
56 {
57   if (EXPR_P (t))
58     add_expr (t);
59 }
60
61 /* Add a fixit hint suggesting replacing the range at MISSPELLED_TOKEN_LOC
62    with the identifier HINT_ID.  */
63
64 void
65 gcc_rich_location::add_fixit_misspelled_id (location_t misspelled_token_loc,
66                                             tree hint_id)
67 {
68   gcc_assert (TREE_CODE (hint_id) == IDENTIFIER_NODE);
69
70   add_fixit_replace (misspelled_token_loc, IDENTIFIER_POINTER (hint_id));
71 }