| 1 |
/* Language-independent diagnostic subroutines that implicitly use global_dc. |
| 2 |
Copyright (C) 1999-2025 Free Software Foundation, Inc. |
| 3 |
Contributed by Gabriel Dos Reis <[email protected]> |
| 4 |
|
| 5 |
This file is part of GCC. |
| 6 |
|
| 7 |
GCC is free software; you can redistribute it and/or modify it under |
| 8 |
the terms of the GNU General Public License as published by the Free |
| 9 |
Software Foundation; either version 3, or (at your option) any later |
| 10 |
version. |
| 11 |
|
| 12 |
GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 |
for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with GCC; see the file COPYING3. If not see |
| 19 |
<http://www.gnu.org/licenses/>. */ |
| 20 |
|
| 21 |
|
| 22 |
/* This file implements the parts of the language independent aspect |
| 23 |
of diagnostic messages that implicitly use global_dc. */ |
| 24 |
|
| 25 |
#include "config.h" |
| 26 |
#include "system.h" |
| 27 |
#include "coretypes.h" |
| 28 |
#include "intl.h" |
| 29 |
#include "diagnostic.h" |
| 30 |
#include "diagnostic-format.h" |
| 31 |
|
| 32 |
/* A diagnostic_context surrogate for stderr. */ |
| 33 |
static diagnostic_context global_diagnostic_context; |
| 34 |
diagnostic_context *global_dc = &global_diagnostic_context; |
| 35 |
|
| 36 |
/* Standard error reporting routines in increasing order of severity. */ |
| 37 |
|
| 38 |
/* Text to be emitted verbatim to the error message stream; this |
| 39 |
produces no prefix and disables line-wrapping. Use rarely. |
| 40 |
It is ignored for machine-readable output formats. */ |
| 41 |
void |
| 42 |
verbatim (const char *gmsgid, ...) |
| 43 |
{ |
| 44 |
va_list ap; |
| 45 |
|
| 46 |
va_start (ap, gmsgid); |
| 47 |
text_info text (_(gmsgid), &ap, errno); |
| 48 |
global_dc->report_verbatim (text); |
| 49 |
va_end (ap); |
| 50 |
} |
| 51 |
|
| 52 |
/* Wrapper around diagnostic_context::diagnostic_impl |
| 53 |
implying global_dc and taking a variable argument list. */ |
| 54 |
|
| 55 |
bool |
| 56 |
emit_diagnostic (diagnostic_t kind, |
| 57 |
location_t location, |
| 58 |
diagnostic_option_id option_id, |
| 59 |
const char *gmsgid, ...) |
| 60 |
{ |
| 61 |
auto_diagnostic_group d; |
| 62 |
va_list ap; |
| 63 |
va_start (ap, gmsgid); |
| 64 |
rich_location richloc (line_table, location); |
| 65 |
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id, |
| 66 |
gmsgid, &ap, kind); |
| 67 |
va_end (ap); |
| 68 |
return ret; |
| 69 |
} |
| 70 |
|
| 71 |
/* As above, but for rich_location *. */ |
| 72 |
|
| 73 |
bool |
| 74 |
emit_diagnostic (diagnostic_t kind, |
| 75 |
rich_location *richloc, |
| 76 |
diagnostic_option_id option_id, |
| 77 |
const char *gmsgid, ...) |
| 78 |
{ |
| 79 |
auto_diagnostic_group d; |
| 80 |
va_list ap; |
| 81 |
va_start (ap, gmsgid); |
| 82 |
bool ret = global_dc->diagnostic_impl (richloc, nullptr, option_id, |
| 83 |
gmsgid, &ap, kind); |
| 84 |
va_end (ap); |
| 85 |
return ret; |
| 86 |
} |
| 87 |
|
| 88 |
/* As above, but taking a variable argument list. */ |
| 89 |
|
| 90 |
bool |
| 91 |
emit_diagnostic_valist (diagnostic_t kind, |
| 92 |
location_t location, |
| 93 |
diagnostic_option_id option_id, |
| 94 |
const char *gmsgid, va_list *ap) |
| 95 |
{ |
| 96 |
rich_location richloc (line_table, location); |
| 97 |
return global_dc->diagnostic_impl (&richloc, nullptr, option_id, |
| 98 |
gmsgid, ap, kind); |
| 99 |
} |
| 100 |
|
| 101 |
/* As above, but with rich_location and metadata. */ |
| 102 |
|
| 103 |
bool |
| 104 |
emit_diagnostic_valist_meta (diagnostic_t kind, |
| 105 |
rich_location *richloc, |
| 106 |
const diagnostic_metadata *metadata, |
| 107 |
diagnostic_option_id option_id, |
| 108 |
const char *gmsgid, va_list *ap) |
| 109 |
{ |
| 110 |
return global_dc->diagnostic_impl (richloc, metadata, option_id, |
| 111 |
gmsgid, ap, kind); |
| 112 |
} |
| 113 |
|
| 114 |
/* An informative note at LOCATION. Use this for additional details on an error |
| 115 |
message. */ |
| 116 |
void |
| 117 |
inform (location_t location, const char *gmsgid, ...) |
| 118 |
{ |
| 119 |
auto_diagnostic_group d; |
| 120 |
va_list ap; |
| 121 |
va_start (ap, gmsgid); |
| 122 |
rich_location richloc (line_table, location); |
| 123 |
global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_NOTE); |
| 124 |
va_end (ap); |
| 125 |
} |
| 126 |
|
| 127 |
/* Same as "inform" above, but at RICHLOC. */ |
| 128 |
void |
| 129 |
inform (rich_location *richloc, const char *gmsgid, ...) |
| 130 |
{ |
| 131 |
gcc_assert (richloc); |
| 132 |
|
| 133 |
auto_diagnostic_group d; |
| 134 |
va_list ap; |
| 135 |
va_start (ap, gmsgid); |
| 136 |
global_dc->diagnostic_impl (richloc, nullptr, -1, gmsgid, &ap, DK_NOTE); |
| 137 |
va_end (ap); |
| 138 |
} |
| 139 |
|
| 140 |
/* An informative note at LOCATION. Use this for additional details on an |
| 141 |
error message. */ |
| 142 |
void |
| 143 |
inform_n (location_t location, unsigned HOST_WIDE_INT n, |
| 144 |
const char *singular_gmsgid, const char *plural_gmsgid, ...) |
| 145 |
{ |
| 146 |
va_list ap; |
| 147 |
va_start (ap, plural_gmsgid); |
| 148 |
auto_diagnostic_group d; |
| 149 |
rich_location richloc (line_table, location); |
| 150 |
global_dc->diagnostic_n_impl (&richloc, nullptr, -1, n, |
| 151 |
singular_gmsgid, plural_gmsgid, |
| 152 |
&ap, DK_NOTE); |
| 153 |
va_end (ap); |
| 154 |
} |
| 155 |
|
| 156 |
/* A warning at INPUT_LOCATION. Use this for code which is correct according |
| 157 |
to the relevant language specification but is likely to be buggy anyway. |
| 158 |
Returns true if the warning was printed, false if it was inhibited. */ |
| 159 |
bool |
| 160 |
warning (diagnostic_option_id option_id, const char *gmsgid, ...) |
| 161 |
{ |
| 162 |
auto_diagnostic_group d; |
| 163 |
va_list ap; |
| 164 |
va_start (ap, gmsgid); |
| 165 |
rich_location richloc (line_table, input_location); |
| 166 |
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id, |
| 167 |
gmsgid, &ap, DK_WARNING); |
| 168 |
va_end (ap); |
| 169 |
return ret; |
| 170 |
} |
| 171 |
|
| 172 |
/* A warning at LOCATION. Use this for code which is correct according to the |
| 173 |
relevant language specification but is likely to be buggy anyway. |
| 174 |
Returns true if the warning was printed, false if it was inhibited. */ |
| 175 |
|
| 176 |
bool |
| 177 |
warning_at (location_t location, |
| 178 |
diagnostic_option_id option_id, |
| 179 |
const char *gmsgid, ...) |
| 180 |
{ |
| 181 |
auto_diagnostic_group d; |
| 182 |
va_list ap; |
| 183 |
va_start (ap, gmsgid); |
| 184 |
rich_location richloc (line_table, location); |
| 185 |
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id, |
| 186 |
gmsgid, &ap, DK_WARNING); |
| 187 |
va_end (ap); |
| 188 |
return ret; |
| 189 |
} |
| 190 |
|
| 191 |
/* Same as "warning at" above, but using RICHLOC. */ |
| 192 |
|
| 193 |
bool |
| 194 |
warning_at (rich_location *richloc, |
| 195 |
diagnostic_option_id option_id, |
| 196 |
const char *gmsgid, ...) |
| 197 |
{ |
| 198 |
gcc_assert (richloc); |
| 199 |
|
| 200 |
auto_diagnostic_group d; |
| 201 |
va_list ap; |
| 202 |
va_start (ap, gmsgid); |
| 203 |
bool ret = global_dc->diagnostic_impl (richloc, nullptr, option_id, |
| 204 |
gmsgid, &ap, DK_WARNING); |
| 205 |
va_end (ap); |
| 206 |
return ret; |
| 207 |
} |
| 208 |
|
| 209 |
/* Same as "warning at" above, but using METADATA. */ |
| 210 |
|
| 211 |
bool |
| 212 |
warning_meta (rich_location *richloc, |
| 213 |
const diagnostic_metadata &metadata, |
| 214 |
diagnostic_option_id option_id, |
| 215 |
const char *gmsgid, ...) |
| 216 |
{ |
| 217 |
gcc_assert (richloc); |
| 218 |
|
| 219 |
auto_diagnostic_group d; |
| 220 |
va_list ap; |
| 221 |
va_start (ap, gmsgid); |
| 222 |
bool ret = global_dc->diagnostic_impl (richloc, &metadata, option_id, |
| 223 |
gmsgid, &ap, DK_WARNING); |
| 224 |
va_end (ap); |
| 225 |
return ret; |
| 226 |
} |
| 227 |
|
| 228 |
/* Same as warning_n plural variant below, but using RICHLOC. */ |
| 229 |
|
| 230 |
bool |
| 231 |
warning_n (rich_location *richloc, |
| 232 |
diagnostic_option_id option_id, |
| 233 |
unsigned HOST_WIDE_INT n, |
| 234 |
const char *singular_gmsgid, const char *plural_gmsgid, ...) |
| 235 |
{ |
| 236 |
gcc_assert (richloc); |
| 237 |
|
| 238 |
auto_diagnostic_group d; |
| 239 |
va_list ap; |
| 240 |
va_start (ap, plural_gmsgid); |
| 241 |
bool ret = global_dc->diagnostic_n_impl (richloc, nullptr, option_id, n, |
| 242 |
singular_gmsgid, plural_gmsgid, |
| 243 |
&ap, DK_WARNING); |
| 244 |
va_end (ap); |
| 245 |
return ret; |
| 246 |
} |
| 247 |
|
| 248 |
/* A warning at LOCATION. Use this for code which is correct according to the |
| 249 |
relevant language specification but is likely to be buggy anyway. |
| 250 |
Returns true if the warning was printed, false if it was inhibited. */ |
| 251 |
|
| 252 |
bool |
| 253 |
warning_n (location_t location, |
| 254 |
diagnostic_option_id option_id, |
| 255 |
unsigned HOST_WIDE_INT n, |
| 256 |
const char *singular_gmsgid, const char *plural_gmsgid, ...) |
| 257 |
{ |
| 258 |
auto_diagnostic_group d; |
| 259 |
va_list ap; |
| 260 |
va_start (ap, plural_gmsgid); |
| 261 |
rich_location richloc (line_table, location); |
| 262 |
bool ret = global_dc->diagnostic_n_impl (&richloc, nullptr, option_id, n, |
| 263 |
singular_gmsgid, plural_gmsgid, |
| 264 |
&ap, DK_WARNING); |
| 265 |
va_end (ap); |
| 266 |
return ret; |
| 267 |
} |
| 268 |
|
| 269 |
/* A "pedantic" warning at LOCATION: issues a warning unless |
| 270 |
-pedantic-errors was given on the command line, in which case it |
| 271 |
issues an error. Use this for diagnostics required by the relevant |
| 272 |
language standard, if you have chosen not to make them errors. |
| 273 |
|
| 274 |
Note that these diagnostics are issued independent of the setting |
| 275 |
of the -Wpedantic command-line switch. To get a warning enabled |
| 276 |
only with that switch, use either "if (pedantic) pedwarn |
| 277 |
(OPT_Wpedantic,...)" or just "pedwarn (OPT_Wpedantic,..)". To get a |
| 278 |
pedwarn independently of the -Wpedantic switch use "pedwarn (0,...)". |
| 279 |
|
| 280 |
Returns true if the warning was printed, false if it was inhibited. */ |
| 281 |
|
| 282 |
bool |
| 283 |
pedwarn (location_t location, |
| 284 |
diagnostic_option_id option_id, |
| 285 |
const char *gmsgid, ...) |
| 286 |
{ |
| 287 |
auto_diagnostic_group d; |
| 288 |
va_list ap; |
| 289 |
va_start (ap, gmsgid); |
| 290 |
rich_location richloc (line_table, location); |
| 291 |
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id, |
| 292 |
gmsgid, &ap, DK_PEDWARN); |
| 293 |
va_end (ap); |
| 294 |
return ret; |
| 295 |
} |
| 296 |
|
| 297 |
/* Same as pedwarn above, but using RICHLOC. */ |
| 298 |
|
| 299 |
bool |
| 300 |
pedwarn (rich_location *richloc, |
| 301 |
diagnostic_option_id option_id, |
| 302 |
const char *gmsgid, ...) |
| 303 |
{ |
| 304 |
gcc_assert (richloc); |
| 305 |
|
| 306 |
auto_diagnostic_group d; |
| 307 |
va_list ap; |
| 308 |
va_start (ap, gmsgid); |
| 309 |
bool ret = global_dc->diagnostic_impl (richloc, nullptr, option_id, |
| 310 |
gmsgid, &ap, DK_PEDWARN); |
| 311 |
va_end (ap); |
| 312 |
return ret; |
| 313 |
} |
| 314 |
|
| 315 |
/* A "permissive" error at LOCATION: issues an error unless |
| 316 |
-fpermissive was given on the command line, in which case it issues |
| 317 |
a warning. Use this for things that really should be errors but we |
| 318 |
want to support legacy code. |
| 319 |
|
| 320 |
Returns true if the warning was printed, false if it was inhibited. */ |
| 321 |
|
| 322 |
bool |
| 323 |
permerror (location_t location, const char *gmsgid, ...) |
| 324 |
{ |
| 325 |
auto_diagnostic_group d; |
| 326 |
va_list ap; |
| 327 |
va_start (ap, gmsgid); |
| 328 |
rich_location richloc (line_table, location); |
| 329 |
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, |
| 330 |
DK_PERMERROR); |
| 331 |
va_end (ap); |
| 332 |
return ret; |
| 333 |
} |
| 334 |
|
| 335 |
/* Same as "permerror" above, but at RICHLOC. */ |
| 336 |
|
| 337 |
bool |
| 338 |
permerror (rich_location *richloc, const char *gmsgid, ...) |
| 339 |
{ |
| 340 |
gcc_assert (richloc); |
| 341 |
|
| 342 |
auto_diagnostic_group d; |
| 343 |
va_list ap; |
| 344 |
va_start (ap, gmsgid); |
| 345 |
bool ret = global_dc->diagnostic_impl (richloc, nullptr, -1, gmsgid, &ap, |
| 346 |
DK_PERMERROR); |
| 347 |
va_end (ap); |
| 348 |
return ret; |
| 349 |
} |
| 350 |
|
| 351 |
/* Similar to the above, but controlled by a flag other than -fpermissive. |
| 352 |
As above, an error by default or a warning with -fpermissive, but this |
| 353 |
diagnostic can also be downgraded by -Wno-error=opt. */ |
| 354 |
|
| 355 |
bool |
| 356 |
permerror_opt (location_t location, |
| 357 |
diagnostic_option_id option_id, |
| 358 |
const char *gmsgid, ...) |
| 359 |
{ |
| 360 |
auto_diagnostic_group d; |
| 361 |
va_list ap; |
| 362 |
va_start (ap, gmsgid); |
| 363 |
rich_location richloc (line_table, location); |
| 364 |
bool ret = global_dc->diagnostic_impl (&richloc, nullptr, option_id, |
| 365 |
gmsgid, &ap, DK_PERMERROR); |
| 366 |
va_end (ap); |
| 367 |
return ret; |
| 368 |
} |
| 369 |
|
| 370 |
/* Same as "permerror" above, but at RICHLOC. */ |
| 371 |
|
| 372 |
bool |
| 373 |
permerror_opt (rich_location *richloc, |
| 374 |
diagnostic_option_id option_id, |
| 375 |
const char *gmsgid, ...) |
| 376 |
{ |
| 377 |
gcc_assert (richloc); |
| 378 |
|
| 379 |
auto_diagnostic_group d; |
| 380 |
va_list ap; |
| 381 |
va_start (ap, gmsgid); |
| 382 |
bool ret = global_dc->diagnostic_impl (richloc, nullptr, option_id, |
| 383 |
gmsgid, &ap, DK_PERMERROR); |
| 384 |
va_end (ap); |
| 385 |
return ret; |
| 386 |
} |
| 387 |
|
| 388 |
/* A hard error: the code is definitely ill-formed, and an object file |
| 389 |
will not be produced. */ |
| 390 |
void |
| 391 |
error (const char *gmsgid, ...) |
| 392 |
{ |
| 393 |
auto_diagnostic_group d; |
| 394 |
va_list ap; |
| 395 |
va_start (ap, gmsgid); |
| 396 |
rich_location richloc (line_table, input_location); |
| 397 |
global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ERROR); |
| 398 |
va_end (ap); |
| 399 |
} |
| 400 |
|
| 401 |
/* A hard error: the code is definitely ill-formed, and an object file |
| 402 |
will not be produced. */ |
| 403 |
void |
| 404 |
error_n (location_t location, unsigned HOST_WIDE_INT n, |
| 405 |
const char *singular_gmsgid, const char *plural_gmsgid, ...) |
| 406 |
{ |
| 407 |
auto_diagnostic_group d; |
| 408 |
va_list ap; |
| 409 |
va_start (ap, plural_gmsgid); |
| 410 |
rich_location richloc (line_table, location); |
| 411 |
global_dc->diagnostic_n_impl (&richloc, nullptr, -1, n, |
| 412 |
singular_gmsgid, plural_gmsgid, |
| 413 |
&ap, DK_ERROR); |
| 414 |
va_end (ap); |
| 415 |
} |
| 416 |
|
| 417 |
/* Same as above, but use location LOC instead of input_location. */ |
| 418 |
void |
| 419 |
error_at (location_t loc, const char *gmsgid, ...) |
| 420 |
{ |
| 421 |
auto_diagnostic_group d; |
| 422 |
va_list ap; |
| 423 |
va_start (ap, gmsgid); |
| 424 |
rich_location richloc (line_table, loc); |
| 425 |
global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ERROR); |
| 426 |
va_end (ap); |
| 427 |
} |
| 428 |
|
| 429 |
/* Same as above, but use RICH_LOC. */ |
| 430 |
|
| 431 |
void |
| 432 |
error_at (rich_location *richloc, const char *gmsgid, ...) |
| 433 |
{ |
| 434 |
gcc_assert (richloc); |
| 435 |
|
| 436 |
auto_diagnostic_group d; |
| 437 |
va_list ap; |
| 438 |
va_start (ap, gmsgid); |
| 439 |
global_dc->diagnostic_impl (richloc, nullptr, -1, gmsgid, &ap, DK_ERROR); |
| 440 |
va_end (ap); |
| 441 |
} |
| 442 |
|
| 443 |
/* Same as above, but with metadata. */ |
| 444 |
|
| 445 |
void |
| 446 |
error_meta (rich_location *richloc, const diagnostic_metadata &metadata, |
| 447 |
const char *gmsgid, ...) |
| 448 |
{ |
| 449 |
gcc_assert (richloc); |
| 450 |
|
| 451 |
auto_diagnostic_group d; |
| 452 |
va_list ap; |
| 453 |
va_start (ap, gmsgid); |
| 454 |
global_dc->diagnostic_impl (richloc, &metadata, -1, gmsgid, &ap, DK_ERROR); |
| 455 |
va_end (ap); |
| 456 |
} |
| 457 |
|
| 458 |
/* "Sorry, not implemented." Use for a language feature which is |
| 459 |
required by the relevant specification but not implemented by GCC. |
| 460 |
An object file will not be produced. */ |
| 461 |
void |
| 462 |
sorry (const char *gmsgid, ...) |
| 463 |
{ |
| 464 |
auto_diagnostic_group d; |
| 465 |
va_list ap; |
| 466 |
va_start (ap, gmsgid); |
| 467 |
rich_location richloc (line_table, input_location); |
| 468 |
global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_SORRY); |
| 469 |
va_end (ap); |
| 470 |
} |
| 471 |
|
| 472 |
/* Same as above, but use location LOC instead of input_location. */ |
| 473 |
void |
| 474 |
sorry_at (location_t loc, const char *gmsgid, ...) |
| 475 |
{ |
| 476 |
auto_diagnostic_group d; |
| 477 |
va_list ap; |
| 478 |
va_start (ap, gmsgid); |
| 479 |
rich_location richloc (line_table, loc); |
| 480 |
global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_SORRY); |
| 481 |
va_end (ap); |
| 482 |
} |
| 483 |
|
| 484 |
/* Return true if an error or a "sorry" has been seen on global_dc. Various |
| 485 |
processing is disabled after errors. */ |
| 486 |
bool |
| 487 |
seen_error (void) |
| 488 |
{ |
| 489 |
return errorcount || sorrycount; |
| 490 |
} |
| 491 |
|
| 492 |
/* An error which is severe enough that we make no attempt to |
| 493 |
continue. Do not use this for internal consistency checks; that's |
| 494 |
internal_error. Use of this function should be rare. */ |
| 495 |
void |
| 496 |
fatal_error (location_t loc, const char *gmsgid, ...) |
| 497 |
{ |
| 498 |
auto_diagnostic_group d; |
| 499 |
va_list ap; |
| 500 |
va_start (ap, gmsgid); |
| 501 |
rich_location richloc (line_table, loc); |
| 502 |
global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_FATAL); |
| 503 |
va_end (ap); |
| 504 |
|
| 505 |
gcc_unreachable (); |
| 506 |
} |
| 507 |
|
| 508 |
/* An internal consistency check has failed. We make no attempt to |
| 509 |
continue. */ |
| 510 |
void |
| 511 |
internal_error (const char *gmsgid, ...) |
| 512 |
{ |
| 513 |
auto_diagnostic_group d; |
| 514 |
va_list ap; |
| 515 |
va_start (ap, gmsgid); |
| 516 |
rich_location richloc (line_table, input_location); |
| 517 |
global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ICE); |
| 518 |
va_end (ap); |
| 519 |
|
| 520 |
gcc_unreachable (); |
| 521 |
} |
| 522 |
|
| 523 |
/* Like internal_error, but no backtrace will be printed. Used when |
| 524 |
the internal error does not happen at the current location, but happened |
| 525 |
somewhere else. */ |
| 526 |
void |
| 527 |
internal_error_no_backtrace (const char *gmsgid, ...) |
| 528 |
{ |
| 529 |
auto_diagnostic_group d; |
| 530 |
va_list ap; |
| 531 |
va_start (ap, gmsgid); |
| 532 |
rich_location richloc (line_table, input_location); |
| 533 |
global_dc->diagnostic_impl (&richloc, nullptr, -1, gmsgid, &ap, DK_ICE_NOBT); |
| 534 |
va_end (ap); |
| 535 |
|
| 536 |
gcc_unreachable (); |
| 537 |
} |
| 538 |
|
| 539 |
|
| 540 |
/* Special case error functions. Most are implemented in terms of the |
| 541 |
above, or should be. */ |
| 542 |
|
| 543 |
/* Print a diagnostic MSGID on FILE. This is just fprintf, except it |
| 544 |
runs its second argument through gettext. */ |
| 545 |
void |
| 546 |
fnotice (FILE *file, const char *cmsgid, ...) |
| 547 |
{ |
| 548 |
/* If the user requested one of the machine-readable diagnostic output |
| 549 |
formats on stderr (e.g. -fdiagnostics-format=sarif-stderr), then |
| 550 |
emitting free-form text on stderr will lead to corrupt output. |
| 551 |
Skip the message for such cases. */ |
| 552 |
if (file == stderr && global_dc) |
| 553 |
if (!global_dc->supports_fnotice_on_stderr_p ()) |
| 554 |
return; |
| 555 |
|
| 556 |
va_list ap; |
| 557 |
|
| 558 |
va_start (ap, cmsgid); |
| 559 |
vfprintf (file, _(cmsgid), ap); |
| 560 |
va_end (ap); |
| 561 |
} |
| 562 |
|
| 563 |
/* class auto_diagnostic_group. */ |
| 564 |
|
| 565 |
/* Constructor: "push" this group into global_dc. */ |
| 566 |
|
| 567 |
auto_diagnostic_group::auto_diagnostic_group () |
| 568 |
{ |
| 569 |
global_dc->begin_group (); |
| 570 |
} |
| 571 |
|
| 572 |
/* Destructor: "pop" this group from global_dc. */ |
| 573 |
|
| 574 |
auto_diagnostic_group::~auto_diagnostic_group () |
| 575 |
{ |
| 576 |
global_dc->end_group (); |
| 577 |
} |
| 578 |
|
| 579 |
/* class auto_diagnostic_nesting_level. */ |
| 580 |
|
| 581 |
auto_diagnostic_nesting_level::auto_diagnostic_nesting_level () |
| 582 |
{ |
| 583 |
global_dc->push_nesting_level (); |
| 584 |
} |
| 585 |
|
| 586 |
auto_diagnostic_nesting_level::~auto_diagnostic_nesting_level () |
| 587 |
{ |
| 588 |
global_dc->pop_nesting_level (); |
| 589 |
} |