annotate gcc/substring-locations.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Source locations within string literals.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2016-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of GCC.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
9 version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
14 for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 #include "config.h"
kono
parents:
diff changeset
21 #include "system.h"
kono
parents:
diff changeset
22 #include "coretypes.h"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
23 #include "intl.h"
111
kono
parents:
diff changeset
24 #include "diagnostic.h"
kono
parents:
diff changeset
25 #include "cpplib.h"
kono
parents:
diff changeset
26 #include "tree.h"
kono
parents:
diff changeset
27 #include "langhooks.h"
kono
parents:
diff changeset
28 #include "substring-locations.h"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
29 #include "gcc-rich-location.h"
111
kono
parents:
diff changeset
30
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
31 /* format_string_diagnostic_t's ctor, giving information for use by
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
32 the emit_warning* member functions, as follows:
111
kono
parents:
diff changeset
33
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
34 They attempt to obtain precise location information within a string
111
kono
parents:
diff changeset
35 literal from FMT_LOC.
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 Case 1: if substring location is available, and is within the range of
kono
parents:
diff changeset
38 the format string itself, the primary location of the
kono
parents:
diff changeset
39 diagnostic is the substring range obtained from FMT_LOC, with the
kono
parents:
diff changeset
40 caret at the *end* of the substring range.
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 For example:
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 test.c:90:10: warning: problem with '%i' here [-Wformat=]
kono
parents:
diff changeset
45 printf ("hello %i", msg);
kono
parents:
diff changeset
46 ~^
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 Case 2: if the substring location is available, but is not within
kono
parents:
diff changeset
49 the range of the format string, the primary location is that of the
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
50 format string, and a note is emitted showing the substring location.
111
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 For example:
kono
parents:
diff changeset
53 test.c:90:10: warning: problem with '%i' here [-Wformat=]
kono
parents:
diff changeset
54 printf("hello " INT_FMT " world", msg);
kono
parents:
diff changeset
55 ^~~~~~~~~~~~~~~~~~~~~~~~~
kono
parents:
diff changeset
56 test.c:19: note: format string is defined here
kono
parents:
diff changeset
57 #define INT_FMT "%i"
kono
parents:
diff changeset
58 ~^
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 Case 3: if precise substring information is unavailable, the primary
kono
parents:
diff changeset
61 location is that of the whole string passed to FMT_LOC's constructor.
kono
parents:
diff changeset
62 For example:
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 test.c:90:10: warning: problem with '%i' here [-Wformat=]
kono
parents:
diff changeset
65 printf(fmt, msg);
kono
parents:
diff changeset
66 ^~~
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 For each of cases 1-3, if param_loc is not UNKNOWN_LOCATION, then it is used
kono
parents:
diff changeset
69 as a secondary range within the warning. For example, here it
kono
parents:
diff changeset
70 is used with case 1:
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 test.c:90:16: warning: '%s' here but arg 2 has 'long' type [-Wformat=]
kono
parents:
diff changeset
73 printf ("foo %s bar", long_i + long_j);
kono
parents:
diff changeset
74 ~^ ~~~~~~~~~~~~~~~
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 and here with case 2:
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 test.c:90:16: warning: '%s' here but arg 2 has 'long' type [-Wformat=]
kono
parents:
diff changeset
79 printf ("foo " STR_FMT " bar", long_i + long_j);
kono
parents:
diff changeset
80 ^~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
kono
parents:
diff changeset
81 test.c:89:16: note: format string is defined here
kono
parents:
diff changeset
82 #define STR_FMT "%s"
kono
parents:
diff changeset
83 ~^
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 and with case 3:
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 test.c:90:10: warning: '%i' here, but arg 2 is "const char *' [-Wformat=]
kono
parents:
diff changeset
88 printf(fmt, msg);
kono
parents:
diff changeset
89 ^~~ ~~~
kono
parents:
diff changeset
90
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
91 If non-NULL, then FMT_LABEL will be used to label the location within the
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
92 string for cases 1 and 2; if non-NULL, then PARAM_LABEL will be used to label
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
93 the parameter. For example with case 1:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
94
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
95 test.c:90:16: warning: '%s' here but arg 2 has 'long' type [-Wformat=]
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
96 printf ("foo %s bar", long_i + long_j);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
97 ~^ ~~~~~~~~~~~~~~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
98 |
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
99 int
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
100
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
101 and with case 2:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
102
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
103 test.c:90:10: warning: problem with '%i' here [-Wformat=]
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
104 printf("hello " INT_FMT " world", msg);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
105 ^~~~~~~~~~~~~~~~~~~~~~~~~
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
106 test.c:19: note: format string is defined here
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
107 #define INT_FMT "%i"
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
108 ~^
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
109 |
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
110 int
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
111
111
kono
parents:
diff changeset
112 If CORRECTED_SUBSTRING is non-NULL, use it for cases 1 and 2 to provide
kono
parents:
diff changeset
113 a fix-it hint, suggesting that it should replace the text within the
kono
parents:
diff changeset
114 substring range. For example:
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 test.c:90:10: warning: problem with '%i' here [-Wformat=]
kono
parents:
diff changeset
117 printf ("hello %i", msg);
kono
parents:
diff changeset
118 ~^
kono
parents:
diff changeset
119 %s
kono
parents:
diff changeset
120
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
121 */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
122
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
123 format_string_diagnostic_t::
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
124 format_string_diagnostic_t (const substring_loc &fmt_loc,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
125 const range_label *fmt_label,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
126 location_t param_loc,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
127 const range_label *param_label,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
128 const char *corrected_substring)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
129 : m_fmt_loc (fmt_loc),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
130 m_fmt_label (fmt_label),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
131 m_param_loc (param_loc),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
132 m_param_label (param_label),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
133 m_corrected_substring (corrected_substring)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
134 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
135 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
136
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
137 /* Emit a warning governed by option OPT, using SINGULAR_GMSGID as the
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
138 format string (or if PLURAL_GMSGID is different from SINGULAR_GMSGID,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
139 using SINGULAR_GMSGID, PLURAL_GMSGID and N as arguments to ngettext)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
140 and AP as its arguments.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
141
111
kono
parents:
diff changeset
142 Return true if a warning was emitted, false otherwise. */
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 bool
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
145 format_string_diagnostic_t::emit_warning_n_va (int opt,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
146 unsigned HOST_WIDE_INT n,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
147 const char *singular_gmsgid,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
148 const char *plural_gmsgid,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
149 va_list *ap) const
111
kono
parents:
diff changeset
150 {
kono
parents:
diff changeset
151 bool substring_within_range = false;
kono
parents:
diff changeset
152 location_t primary_loc;
kono
parents:
diff changeset
153 location_t fmt_substring_loc = UNKNOWN_LOCATION;
kono
parents:
diff changeset
154 source_range fmt_loc_range
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
155 = get_range_from_loc (line_table, m_fmt_loc.get_fmt_string_loc ());
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
156 const char *err = m_fmt_loc.get_location (&fmt_substring_loc);
111
kono
parents:
diff changeset
157 source_range fmt_substring_range
kono
parents:
diff changeset
158 = get_range_from_loc (line_table, fmt_substring_loc);
kono
parents:
diff changeset
159 if (err)
kono
parents:
diff changeset
160 /* Case 3: unable to get substring location. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
161 primary_loc = m_fmt_loc.get_fmt_string_loc ();
111
kono
parents:
diff changeset
162 else
kono
parents:
diff changeset
163 {
kono
parents:
diff changeset
164 if (fmt_substring_range.m_start >= fmt_loc_range.m_start
kono
parents:
diff changeset
165 && fmt_substring_range.m_start <= fmt_loc_range.m_finish
kono
parents:
diff changeset
166 && fmt_substring_range.m_finish >= fmt_loc_range.m_start
kono
parents:
diff changeset
167 && fmt_substring_range.m_finish <= fmt_loc_range.m_finish)
kono
parents:
diff changeset
168 /* Case 1. */
kono
parents:
diff changeset
169 {
kono
parents:
diff changeset
170 substring_within_range = true;
kono
parents:
diff changeset
171 primary_loc = fmt_substring_loc;
kono
parents:
diff changeset
172 }
kono
parents:
diff changeset
173 else
kono
parents:
diff changeset
174 /* Case 2. */
kono
parents:
diff changeset
175 {
kono
parents:
diff changeset
176 substring_within_range = false;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
177 primary_loc = m_fmt_loc.get_fmt_string_loc ();
111
kono
parents:
diff changeset
178 }
kono
parents:
diff changeset
179 }
kono
parents:
diff changeset
180
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
181 /* Only use fmt_label in the initial warning for case 1. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
182 const range_label *primary_label = NULL;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
183 if (substring_within_range)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
184 primary_label = m_fmt_label;
111
kono
parents:
diff changeset
185
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
186 auto_diagnostic_group d;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
187 gcc_rich_location richloc (primary_loc, primary_label);
111
kono
parents:
diff changeset
188
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
189 if (m_param_loc != UNKNOWN_LOCATION)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
190 richloc.add_range (m_param_loc, SHOW_RANGE_WITHOUT_CARET, m_param_label);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
191
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
192 if (!err && m_corrected_substring && substring_within_range)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
193 richloc.add_fixit_replace (fmt_substring_range, m_corrected_substring);
111
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 diagnostic_info diagnostic;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
196 if (singular_gmsgid != plural_gmsgid)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
197 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
198 unsigned long gtn;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
199
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
200 if (sizeof n <= sizeof gtn)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
201 gtn = n;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
202 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
203 /* Use the largest number ngettext can handle, otherwise
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
204 preserve the six least significant decimal digits for
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
205 languages where the plural form depends on them. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
206 gtn = n <= ULONG_MAX ? n : n % 1000000LU + 1000000LU;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
207
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
208 const char *text = ngettext (singular_gmsgid, plural_gmsgid, gtn);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
209 diagnostic_set_info_translated (&diagnostic, text, ap, &richloc,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
210 DK_WARNING);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
211 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
212 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
213 diagnostic_set_info (&diagnostic, singular_gmsgid, ap, &richloc,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
214 DK_WARNING);
111
kono
parents:
diff changeset
215 diagnostic.option_index = opt;
kono
parents:
diff changeset
216 bool warned = diagnostic_report_diagnostic (global_dc, &diagnostic);
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 if (!err && fmt_substring_loc && !substring_within_range)
kono
parents:
diff changeset
219 /* Case 2. */
kono
parents:
diff changeset
220 if (warned)
kono
parents:
diff changeset
221 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
222 /* Use fmt_label in the note for case 2. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
223 rich_location substring_richloc (line_table, fmt_substring_loc,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
224 m_fmt_label);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
225 if (m_corrected_substring)
111
kono
parents:
diff changeset
226 substring_richloc.add_fixit_replace (fmt_substring_range,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
227 m_corrected_substring);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
228 inform (&substring_richloc,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
229 "format string is defined here");
111
kono
parents:
diff changeset
230 }
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 return warned;
kono
parents:
diff changeset
233 }
kono
parents:
diff changeset
234
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
235 /* Singular-only version of the above. */
111
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 bool
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
238 format_string_diagnostic_t::emit_warning_va (int opt, const char *gmsgid,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
239 va_list *ap) const
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
240 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
241 return emit_warning_n_va (opt, 0, gmsgid, gmsgid, ap);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
242 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
243
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
244 /* Variadic version of the above (singular only). */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
245
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
246 bool
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
247 format_string_diagnostic_t::emit_warning (int opt, const char *gmsgid,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
248 ...) const
111
kono
parents:
diff changeset
249 {
kono
parents:
diff changeset
250 va_list ap;
kono
parents:
diff changeset
251 va_start (ap, gmsgid);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
252 bool warned = emit_warning_va (opt, gmsgid, &ap);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
253 va_end (ap);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
254
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
255 return warned;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
256 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
257
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
258 /* Variadic version of the above (singular vs plural). */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
259
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
260 bool
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
261 format_string_diagnostic_t::emit_warning_n (int opt, unsigned HOST_WIDE_INT n,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
262 const char *singular_gmsgid,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
263 const char *plural_gmsgid,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
264 ...) const
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
265 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
266 va_list ap;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
267 va_start (ap, plural_gmsgid);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
268 bool warned = emit_warning_n_va (opt, n, singular_gmsgid, plural_gmsgid,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
269 &ap);
111
kono
parents:
diff changeset
270 va_end (ap);
kono
parents:
diff changeset
271
kono
parents:
diff changeset
272 return warned;
kono
parents:
diff changeset
273 }
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 /* Attempt to determine the source location of the substring.
kono
parents:
diff changeset
276 If successful, return NULL and write the source location to *OUT_LOC.
kono
parents:
diff changeset
277 Otherwise return an error message. Error messages are intended
kono
parents:
diff changeset
278 for GCC developers (to help debugging) rather than for end-users. */
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 const char *
kono
parents:
diff changeset
281 substring_loc::get_location (location_t *out_loc) const
kono
parents:
diff changeset
282 {
kono
parents:
diff changeset
283 gcc_assert (out_loc);
kono
parents:
diff changeset
284 return lang_hooks.get_substring_location (*this, out_loc);
kono
parents:
diff changeset
285 }