annotate gcc/tree-diagnostic.c @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Language-independent diagnostic subroutines for the GNU Compiler
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 Collection that are only for use in the compilers proper and not
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 the driver or other programs.
16
kono
parents: 14
diff changeset
4 Copyright (C) 1999-2017 Free Software Foundation, Inc.
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 This file is part of GCC.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 GCC is free software; you can redistribute it and/or modify it under
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 the terms of the GNU General Public License as published by the Free
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 Software Foundation; either version 3, or (at your option) any later
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 version.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 for more details.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 along with GCC; see the file COPYING3. If not see
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 <http://www.gnu.org/licenses/>. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "config.h"
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "system.h"
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #include "coretypes.h"
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #include "tree.h"
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #include "diagnostic.h"
16
kono
parents: 14
diff changeset
27 #include "tree-pretty-print.h"
kono
parents: 14
diff changeset
28 #include "gimple-pretty-print.h"
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 #include "tree-diagnostic.h"
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 #include "langhooks.h"
16
kono
parents: 14
diff changeset
31 #include "intl.h"
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 /* Prints out, if necessary, the name of the current function
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 that caused an error. Called from all error and warning functions. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 diagnostic_report_current_function (diagnostic_context *context,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 diagnostic_info *diagnostic)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 {
16
kono
parents: 14
diff changeset
39 diagnostic_report_current_module (context, diagnostic_location (diagnostic));
kono
parents: 14
diff changeset
40 lang_hooks.print_error_function (context, LOCATION_FILE (input_location),
kono
parents: 14
diff changeset
41 diagnostic);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
16
kono
parents: 14
diff changeset
44 static void
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 default_tree_diagnostic_starter (diagnostic_context *context,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 diagnostic_info *diagnostic)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 diagnostic_report_current_function (context, diagnostic);
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
49 pp_set_prefix (context->printer, diagnostic_build_prefix (context,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
50 diagnostic));
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 }
16
kono
parents: 14
diff changeset
52
kono
parents: 14
diff changeset
53 /* This is a pair made of a location and the line map it originated
kono
parents: 14
diff changeset
54 from. It's used in the maybe_unwind_expanded_macro_loc function
kono
parents: 14
diff changeset
55 below. */
kono
parents: 14
diff changeset
56 struct loc_map_pair
kono
parents: 14
diff changeset
57 {
kono
parents: 14
diff changeset
58 const line_map_macro *map;
kono
parents: 14
diff changeset
59 source_location where;
kono
parents: 14
diff changeset
60 };
kono
parents: 14
diff changeset
61
kono
parents: 14
diff changeset
62
kono
parents: 14
diff changeset
63 /* Unwind the different macro expansions that lead to the token which
kono
parents: 14
diff changeset
64 location is WHERE and emit diagnostics showing the resulting
kono
parents: 14
diff changeset
65 unwound macro expansion trace. Let's look at an example to see how
kono
parents: 14
diff changeset
66 the trace looks like. Suppose we have this piece of code,
kono
parents: 14
diff changeset
67 artificially annotated with the line numbers to increase
kono
parents: 14
diff changeset
68 legibility:
kono
parents: 14
diff changeset
69
kono
parents: 14
diff changeset
70 $ cat -n test.c
kono
parents: 14
diff changeset
71 1 #define OPERATE(OPRD1, OPRT, OPRD2) \
kono
parents: 14
diff changeset
72 2 OPRD1 OPRT OPRD2;
kono
parents: 14
diff changeset
73 3
kono
parents: 14
diff changeset
74 4 #define SHIFTL(A,B) \
kono
parents: 14
diff changeset
75 5 OPERATE (A,<<,B)
kono
parents: 14
diff changeset
76 6
kono
parents: 14
diff changeset
77 7 #define MULT(A) \
kono
parents: 14
diff changeset
78 8 SHIFTL (A,1)
kono
parents: 14
diff changeset
79 9
kono
parents: 14
diff changeset
80 10 void
kono
parents: 14
diff changeset
81 11 g ()
kono
parents: 14
diff changeset
82 12 {
kono
parents: 14
diff changeset
83 13 MULT (1.0);// 1.0 << 1; <-- so this is an error.
kono
parents: 14
diff changeset
84 14 }
kono
parents: 14
diff changeset
85
kono
parents: 14
diff changeset
86 Here is the diagnostic that we want the compiler to generate:
kono
parents: 14
diff changeset
87
kono
parents: 14
diff changeset
88 test.c: In function ‘g’:
kono
parents: 14
diff changeset
89 test.c:5:14: error: invalid operands to binary << (have ‘double’ and ‘int’)
kono
parents: 14
diff changeset
90 test.c:2:9: note: in definition of macro 'OPERATE'
kono
parents: 14
diff changeset
91 test.c:8:3: note: in expansion of macro 'SHIFTL'
kono
parents: 14
diff changeset
92 test.c:13:3: note: in expansion of macro 'MULT'
kono
parents: 14
diff changeset
93
kono
parents: 14
diff changeset
94 The part that goes from the third to the fifth line of this
kono
parents: 14
diff changeset
95 diagnostic (the lines containing the 'note:' string) is called the
kono
parents: 14
diff changeset
96 unwound macro expansion trace. That's the part generated by this
kono
parents: 14
diff changeset
97 function. */
kono
parents: 14
diff changeset
98
kono
parents: 14
diff changeset
99 static void
kono
parents: 14
diff changeset
100 maybe_unwind_expanded_macro_loc (diagnostic_context *context,
kono
parents: 14
diff changeset
101 const diagnostic_info *diagnostic,
kono
parents: 14
diff changeset
102 source_location where)
kono
parents: 14
diff changeset
103 {
kono
parents: 14
diff changeset
104 const struct line_map *map;
kono
parents: 14
diff changeset
105 auto_vec<loc_map_pair> loc_vec;
kono
parents: 14
diff changeset
106 unsigned ix;
kono
parents: 14
diff changeset
107 loc_map_pair loc, *iter;
kono
parents: 14
diff changeset
108
kono
parents: 14
diff changeset
109 map = linemap_lookup (line_table, where);
kono
parents: 14
diff changeset
110 if (!linemap_macro_expansion_map_p (map))
kono
parents: 14
diff changeset
111 return;
kono
parents: 14
diff changeset
112
kono
parents: 14
diff changeset
113 /* Let's unwind the macros that got expanded and led to the token
kono
parents: 14
diff changeset
114 which location is WHERE. We are going to store these macros into
kono
parents: 14
diff changeset
115 LOC_VEC, so that we can later walk it at our convenience to
kono
parents: 14
diff changeset
116 display a somewhat meaningful trace of the macro expansion
kono
parents: 14
diff changeset
117 history to the user. Note that the first macro of the trace
kono
parents: 14
diff changeset
118 (which is OPERATE in the example above) is going to be stored at
kono
parents: 14
diff changeset
119 the beginning of LOC_VEC. */
kono
parents: 14
diff changeset
120
kono
parents: 14
diff changeset
121 do
kono
parents: 14
diff changeset
122 {
kono
parents: 14
diff changeset
123 loc.where = where;
kono
parents: 14
diff changeset
124 loc.map = linemap_check_macro (map);
kono
parents: 14
diff changeset
125
kono
parents: 14
diff changeset
126 loc_vec.safe_push (loc);
kono
parents: 14
diff changeset
127
kono
parents: 14
diff changeset
128 /* WHERE is the location of a token inside the expansion of a
kono
parents: 14
diff changeset
129 macro. MAP is the map holding the locations of that macro
kono
parents: 14
diff changeset
130 expansion. Let's get the location of the token inside the
kono
parents: 14
diff changeset
131 context that triggered the expansion of this macro.
kono
parents: 14
diff changeset
132 This is basically how we go "down" in the trace of macro
kono
parents: 14
diff changeset
133 expansions that led to WHERE. */
kono
parents: 14
diff changeset
134 where = linemap_unwind_toward_expansion (line_table, where, &map);
kono
parents: 14
diff changeset
135 } while (linemap_macro_expansion_map_p (map));
kono
parents: 14
diff changeset
136
kono
parents: 14
diff changeset
137 /* Now map is set to the map of the location in the source that
kono
parents: 14
diff changeset
138 first triggered the macro expansion. This must be an ordinary map. */
kono
parents: 14
diff changeset
139 const line_map_ordinary *ord_map = linemap_check_ordinary (map);
kono
parents: 14
diff changeset
140
kono
parents: 14
diff changeset
141 /* Walk LOC_VEC and print the macro expansion trace, unless the
kono
parents: 14
diff changeset
142 first macro which expansion triggered this trace was expanded
kono
parents: 14
diff changeset
143 inside a system header. */
kono
parents: 14
diff changeset
144 int saved_location_line =
kono
parents: 14
diff changeset
145 expand_location_to_spelling_point (diagnostic_location (diagnostic)).line;
kono
parents: 14
diff changeset
146
kono
parents: 14
diff changeset
147 if (!LINEMAP_SYSP (ord_map))
kono
parents: 14
diff changeset
148 FOR_EACH_VEC_ELT (loc_vec, ix, iter)
kono
parents: 14
diff changeset
149 {
kono
parents: 14
diff changeset
150 /* Sometimes, in the unwound macro expansion trace, we want to
kono
parents: 14
diff changeset
151 print a part of the context that shows where, in the
kono
parents: 14
diff changeset
152 definition of the relevant macro, is the token (we are
kono
parents: 14
diff changeset
153 looking at) used. That is the case in the introductory
kono
parents: 14
diff changeset
154 comment of this function, where we print:
kono
parents: 14
diff changeset
155
kono
parents: 14
diff changeset
156 test.c:2:9: note: in definition of macro 'OPERATE'.
kono
parents: 14
diff changeset
157
kono
parents: 14
diff changeset
158 We print that "macro definition context" because the
kono
parents: 14
diff changeset
159 diagnostic line (emitted by the call to
kono
parents: 14
diff changeset
160 pp_ouput_formatted_text in diagnostic_report_diagnostic):
kono
parents: 14
diff changeset
161
kono
parents: 14
diff changeset
162 test.c:5:14: error: invalid operands to binary << (have ‘double’ and ‘int’)
kono
parents: 14
diff changeset
163
kono
parents: 14
diff changeset
164 does not point into the definition of the macro where the
kono
parents: 14
diff changeset
165 token '<<' (that is an argument to the function-like macro
kono
parents: 14
diff changeset
166 OPERATE) is used. So we must "display" the line of that
kono
parents: 14
diff changeset
167 macro definition context to the user somehow.
kono
parents: 14
diff changeset
168
kono
parents: 14
diff changeset
169 A contrario, when the first interesting diagnostic line
kono
parents: 14
diff changeset
170 points into the definition of the macro, we don't need to
kono
parents: 14
diff changeset
171 display any line for that macro definition in the trace
kono
parents: 14
diff changeset
172 anymore, otherwise it'd be redundant. */
kono
parents: 14
diff changeset
173
kono
parents: 14
diff changeset
174 /* Okay, now here is what we want. For each token resulting
kono
parents: 14
diff changeset
175 from macro expansion we want to show: 1/ where in the
kono
parents: 14
diff changeset
176 definition of the macro the token comes from; 2/ where the
kono
parents: 14
diff changeset
177 macro got expanded. */
kono
parents: 14
diff changeset
178
kono
parents: 14
diff changeset
179 /* Resolve the location iter->where into the locus 1/ of the
kono
parents: 14
diff changeset
180 comment above. */
kono
parents: 14
diff changeset
181 source_location resolved_def_loc =
kono
parents: 14
diff changeset
182 linemap_resolve_location (line_table, iter->where,
kono
parents: 14
diff changeset
183 LRK_MACRO_DEFINITION_LOCATION, NULL);
kono
parents: 14
diff changeset
184
kono
parents: 14
diff changeset
185 /* Don't print trace for locations that are reserved or from
kono
parents: 14
diff changeset
186 within a system header. */
kono
parents: 14
diff changeset
187 const line_map_ordinary *m = NULL;
kono
parents: 14
diff changeset
188 source_location l =
kono
parents: 14
diff changeset
189 linemap_resolve_location (line_table, resolved_def_loc,
kono
parents: 14
diff changeset
190 LRK_SPELLING_LOCATION, &m);
kono
parents: 14
diff changeset
191 if (l < RESERVED_LOCATION_COUNT || LINEMAP_SYSP (m))
kono
parents: 14
diff changeset
192 continue;
kono
parents: 14
diff changeset
193
kono
parents: 14
diff changeset
194 /* We need to print the context of the macro definition only
kono
parents: 14
diff changeset
195 when the locus of the first displayed diagnostic (displayed
kono
parents: 14
diff changeset
196 before this trace) was inside the definition of the
kono
parents: 14
diff changeset
197 macro. */
kono
parents: 14
diff changeset
198 int resolved_def_loc_line = SOURCE_LINE (m, l);
kono
parents: 14
diff changeset
199 if (ix == 0 && saved_location_line != resolved_def_loc_line)
kono
parents: 14
diff changeset
200 {
kono
parents: 14
diff changeset
201 diagnostic_append_note (context, resolved_def_loc,
kono
parents: 14
diff changeset
202 "in definition of macro %qs",
kono
parents: 14
diff changeset
203 linemap_map_get_macro_name (iter->map));
kono
parents: 14
diff changeset
204 /* At this step, as we've printed the context of the macro
kono
parents: 14
diff changeset
205 definition, we don't want to print the context of its
kono
parents: 14
diff changeset
206 expansion, otherwise, it'd be redundant. */
kono
parents: 14
diff changeset
207 continue;
kono
parents: 14
diff changeset
208 }
kono
parents: 14
diff changeset
209
kono
parents: 14
diff changeset
210 /* Resolve the location of the expansion point of the macro
kono
parents: 14
diff changeset
211 which expansion gave the token represented by def_loc.
kono
parents: 14
diff changeset
212 This is the locus 2/ of the earlier comment. */
kono
parents: 14
diff changeset
213 source_location resolved_exp_loc =
kono
parents: 14
diff changeset
214 linemap_resolve_location (line_table,
kono
parents: 14
diff changeset
215 MACRO_MAP_EXPANSION_POINT_LOCATION (iter->map),
kono
parents: 14
diff changeset
216 LRK_MACRO_DEFINITION_LOCATION, NULL);
kono
parents: 14
diff changeset
217
kono
parents: 14
diff changeset
218 diagnostic_append_note (context, resolved_exp_loc,
kono
parents: 14
diff changeset
219 "in expansion of macro %qs",
kono
parents: 14
diff changeset
220 linemap_map_get_macro_name (iter->map));
kono
parents: 14
diff changeset
221 }
kono
parents: 14
diff changeset
222 }
kono
parents: 14
diff changeset
223
kono
parents: 14
diff changeset
224 /* This is a diagnostic finalizer implementation that is aware of
kono
parents: 14
diff changeset
225 virtual locations produced by libcpp.
kono
parents: 14
diff changeset
226
kono
parents: 14
diff changeset
227 It has to be called by the diagnostic finalizer of front ends that
kono
parents: 14
diff changeset
228 uses libcpp and wish to get diagnostics involving tokens resulting
kono
parents: 14
diff changeset
229 from macro expansion.
kono
parents: 14
diff changeset
230
kono
parents: 14
diff changeset
231 For a given location, if said location belongs to a token
kono
parents: 14
diff changeset
232 resulting from a macro expansion, this starter prints the context
kono
parents: 14
diff changeset
233 of the token. E.g, for multiply nested macro expansion, it
kono
parents: 14
diff changeset
234 unwinds the nested macro expansions and prints them in a manner
kono
parents: 14
diff changeset
235 that is similar to what is done for function call stacks, or
kono
parents: 14
diff changeset
236 template instantiation contexts. */
kono
parents: 14
diff changeset
237 void
kono
parents: 14
diff changeset
238 virt_loc_aware_diagnostic_finalizer (diagnostic_context *context,
kono
parents: 14
diff changeset
239 diagnostic_info *diagnostic)
kono
parents: 14
diff changeset
240 {
kono
parents: 14
diff changeset
241 maybe_unwind_expanded_macro_loc (context, diagnostic,
kono
parents: 14
diff changeset
242 diagnostic_location (diagnostic));
kono
parents: 14
diff changeset
243 }
kono
parents: 14
diff changeset
244
kono
parents: 14
diff changeset
245 /* Default tree printer. Handles declarations only. */
kono
parents: 14
diff changeset
246 bool
kono
parents: 14
diff changeset
247 default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
kono
parents: 14
diff changeset
248 int precision, bool wide, bool set_locus, bool hash,
kono
parents: 14
diff changeset
249 bool, const char **)
kono
parents: 14
diff changeset
250 {
kono
parents: 14
diff changeset
251 tree t;
kono
parents: 14
diff changeset
252
kono
parents: 14
diff changeset
253 /* FUTURE: %+x should set the locus. */
kono
parents: 14
diff changeset
254 if (precision != 0 || wide || hash)
kono
parents: 14
diff changeset
255 return false;
kono
parents: 14
diff changeset
256
kono
parents: 14
diff changeset
257 switch (*spec)
kono
parents: 14
diff changeset
258 {
kono
parents: 14
diff changeset
259 case 'E':
kono
parents: 14
diff changeset
260 t = va_arg (*text->args_ptr, tree);
kono
parents: 14
diff changeset
261 if (TREE_CODE (t) == IDENTIFIER_NODE)
kono
parents: 14
diff changeset
262 {
kono
parents: 14
diff changeset
263 pp_identifier (pp, IDENTIFIER_POINTER (t));
kono
parents: 14
diff changeset
264 return true;
kono
parents: 14
diff changeset
265 }
kono
parents: 14
diff changeset
266 break;
kono
parents: 14
diff changeset
267
kono
parents: 14
diff changeset
268 case 'D':
kono
parents: 14
diff changeset
269 t = va_arg (*text->args_ptr, tree);
kono
parents: 14
diff changeset
270 if (VAR_P (t) && DECL_HAS_DEBUG_EXPR_P (t))
kono
parents: 14
diff changeset
271 t = DECL_DEBUG_EXPR (t);
kono
parents: 14
diff changeset
272 break;
kono
parents: 14
diff changeset
273
kono
parents: 14
diff changeset
274 case 'F':
kono
parents: 14
diff changeset
275 case 'T':
kono
parents: 14
diff changeset
276 t = va_arg (*text->args_ptr, tree);
kono
parents: 14
diff changeset
277 break;
kono
parents: 14
diff changeset
278
kono
parents: 14
diff changeset
279 case 'G':
kono
parents: 14
diff changeset
280 percent_G_format (text);
kono
parents: 14
diff changeset
281 return true;
kono
parents: 14
diff changeset
282
kono
parents: 14
diff changeset
283 case 'K':
kono
parents: 14
diff changeset
284 t = va_arg (*text->args_ptr, tree);
kono
parents: 14
diff changeset
285 percent_K_format (text, t);
kono
parents: 14
diff changeset
286 return true;
kono
parents: 14
diff changeset
287
kono
parents: 14
diff changeset
288 default:
kono
parents: 14
diff changeset
289 return false;
kono
parents: 14
diff changeset
290 }
kono
parents: 14
diff changeset
291
kono
parents: 14
diff changeset
292 if (set_locus)
kono
parents: 14
diff changeset
293 text->set_location (0, DECL_SOURCE_LOCATION (t), true);
kono
parents: 14
diff changeset
294
kono
parents: 14
diff changeset
295 if (DECL_P (t))
kono
parents: 14
diff changeset
296 {
kono
parents: 14
diff changeset
297 const char *n = DECL_NAME (t)
kono
parents: 14
diff changeset
298 ? identifier_to_locale (lang_hooks.decl_printable_name (t, 2))
kono
parents: 14
diff changeset
299 : _("<anonymous>");
kono
parents: 14
diff changeset
300 pp_string (pp, n);
kono
parents: 14
diff changeset
301 }
kono
parents: 14
diff changeset
302 else
kono
parents: 14
diff changeset
303 dump_generic_node (pp, t, 0, TDF_SLIM, 0);
kono
parents: 14
diff changeset
304
kono
parents: 14
diff changeset
305 return true;
kono
parents: 14
diff changeset
306 }
kono
parents: 14
diff changeset
307
kono
parents: 14
diff changeset
308 /* Sets CONTEXT to use language independent diagnostics. */
kono
parents: 14
diff changeset
309 void
kono
parents: 14
diff changeset
310 tree_diagnostics_defaults (diagnostic_context *context)
kono
parents: 14
diff changeset
311 {
kono
parents: 14
diff changeset
312 diagnostic_starter (context) = default_tree_diagnostic_starter;
kono
parents: 14
diff changeset
313 diagnostic_finalizer (context) = default_diagnostic_finalizer;
kono
parents: 14
diff changeset
314 diagnostic_format_decoder (context) = default_tree_printer;
kono
parents: 14
diff changeset
315 }