GCC Middle and Back End API Reference
diagnostic-global-context.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "intl.h"
#include "diagnostic.h"
#include "diagnostic-format.h"
Include dependency graph for diagnostic-global-context.cc:

Functions

void verbatim (const char *gmsgid,...)
 
bool emit_diagnostic (diagnostic_t kind, location_t location, diagnostic_option_id option_id, const char *gmsgid,...)
 
bool emit_diagnostic (diagnostic_t kind, rich_location *richloc, diagnostic_option_id option_id, const char *gmsgid,...)
 
bool emit_diagnostic_valist (diagnostic_t kind, location_t location, diagnostic_option_id option_id, const char *gmsgid, va_list *ap)
 
bool emit_diagnostic_valist_meta (diagnostic_t kind, rich_location *richloc, const diagnostic_metadata *metadata, diagnostic_option_id option_id, const char *gmsgid, va_list *ap)
 
void inform (location_t location, const char *gmsgid,...)
 
void inform (rich_location *richloc, const char *gmsgid,...)
 
void inform_n (location_t location, unsigned HOST_WIDE_INT n, const char *singular_gmsgid, const char *plural_gmsgid,...)
 
bool warning (diagnostic_option_id option_id, const char *gmsgid,...)
 
bool warning_at (location_t location, diagnostic_option_id option_id, const char *gmsgid,...)
 
bool warning_at (rich_location *richloc, diagnostic_option_id option_id, const char *gmsgid,...)
 
bool warning_meta (rich_location *richloc, const diagnostic_metadata &metadata, diagnostic_option_id option_id, const char *gmsgid,...)
 
bool warning_n (rich_location *richloc, diagnostic_option_id option_id, unsigned HOST_WIDE_INT n, const char *singular_gmsgid, const char *plural_gmsgid,...)
 
bool warning_n (location_t location, diagnostic_option_id option_id, unsigned HOST_WIDE_INT n, const char *singular_gmsgid, const char *plural_gmsgid,...)
 
bool pedwarn (location_t location, diagnostic_option_id option_id, const char *gmsgid,...)
 
bool pedwarn (rich_location *richloc, diagnostic_option_id option_id, const char *gmsgid,...)
 
bool permerror (location_t location, const char *gmsgid,...)
 
bool permerror (rich_location *richloc, const char *gmsgid,...)
 
bool permerror_opt (location_t location, diagnostic_option_id option_id, const char *gmsgid,...)
 
bool permerror_opt (rich_location *richloc, diagnostic_option_id option_id, const char *gmsgid,...)
 
void error (const char *gmsgid,...)
 
void error_n (location_t location, unsigned HOST_WIDE_INT n, const char *singular_gmsgid, const char *plural_gmsgid,...)
 
void error_at (location_t loc, const char *gmsgid,...)
 
void error_at (rich_location *richloc, const char *gmsgid,...)
 
void error_meta (rich_location *richloc, const diagnostic_metadata &metadata, const char *gmsgid,...)
 
void sorry (const char *gmsgid,...)
 
void sorry_at (location_t loc, const char *gmsgid,...)
 
bool seen_error (void)
 
void fatal_error (location_t loc, const char *gmsgid,...)
 
void internal_error (const char *gmsgid,...)
 
void internal_error_no_backtrace (const char *gmsgid,...)
 
void fnotice (FILE *file, const char *cmsgid,...)
 

Variables

static diagnostic_context global_diagnostic_context
 
diagnostic_contextglobal_dc = &global_diagnostic_context
 

Function Documentation

◆ emit_diagnostic() [1/2]

bool emit_diagnostic ( diagnostic_t kind,
location_t location,
diagnostic_option_id option_id,
const char * gmsgid,
... )
Wrapper around diagnostic_context::diagnostic_impl
implying global_dc and taking a variable argument list.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.

◆ emit_diagnostic() [2/2]

bool emit_diagnostic ( diagnostic_t kind,
rich_location * richloc,
diagnostic_option_id option_id,
const char * gmsgid,
... )
As above, but for rich_location *.   

References ap, diagnostic_context::diagnostic_impl(), and global_dc.

◆ emit_diagnostic_valist()

bool emit_diagnostic_valist ( diagnostic_t kind,
location_t location,
diagnostic_option_id option_id,
const char * gmsgid,
va_list * ap )
As above, but taking a variable argument list.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.

◆ emit_diagnostic_valist_meta()

bool emit_diagnostic_valist_meta ( diagnostic_t kind,
rich_location * richloc,
const diagnostic_metadata * metadata,
diagnostic_option_id option_id,
const char * gmsgid,
va_list * ap )
As above, but with rich_location and metadata.   

References ap, diagnostic_context::diagnostic_impl(), and global_dc.

◆ error()

void error ( const char * gmsgid,
... )
A hard error: the code is definitely ill-formed, and an object file
will not be produced.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, input_location, and line_table.

◆ error_at() [1/2]

void error_at ( location_t loc,
const char * gmsgid,
... )
Same as above, but use location LOC instead of input_location.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.

◆ error_at() [2/2]

void error_at ( rich_location * richloc,
const char * gmsgid,
... )
Same as above, but use RICH_LOC.   

References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.

◆ error_meta()

void error_meta ( rich_location * richloc,
const diagnostic_metadata & metadata,
const char * gmsgid,
... )
Same as above, but with metadata.   

References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.

◆ error_n()

void error_n ( location_t location,
unsigned HOST_WIDE_INT n,
const char * singular_gmsgid,
const char * plural_gmsgid,
... )
A hard error: the code is definitely ill-formed, and an object file
will not be produced.   

References ap, diagnostic_context::diagnostic_n_impl(), global_dc, and line_table.

◆ fatal_error()

void fatal_error ( location_t loc,
const char * gmsgid,
... )
An error which is severe enough that we make no attempt to
continue.  Do not use this for internal consistency checks; that's
internal_error.  Use of this function should be rare.   

References ap, diagnostic_context::diagnostic_impl(), gcc_unreachable, global_dc, and line_table.

◆ fnotice()

◆ inform() [1/2]

void inform ( location_t location,
const char * gmsgid,
... )
An informative note at LOCATION.  Use this for additional details on an error
message.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.

◆ inform() [2/2]

void inform ( rich_location * richloc,
const char * gmsgid,
... )
Same as "inform" above, but at RICHLOC.   

References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.

◆ inform_n()

void inform_n ( location_t location,
unsigned HOST_WIDE_INT n,
const char * singular_gmsgid,
const char * plural_gmsgid,
... )
An informative note at LOCATION.  Use this for additional details on an
error message.   

References ap, diagnostic_context::diagnostic_n_impl(), global_dc, and line_table.

◆ internal_error()

void internal_error ( const char * gmsgid,
... )
An internal consistency check has failed.  We make no attempt to
continue.   

References ap, diagnostic_context::diagnostic_impl(), gcc_unreachable, global_dc, input_location, and line_table.

◆ internal_error_no_backtrace()

void internal_error_no_backtrace ( const char * gmsgid,
... )
Like internal_error, but no backtrace will be printed.  Used when
the internal error does not happen at the current location, but happened
somewhere else.   

References ap, diagnostic_context::diagnostic_impl(), gcc_unreachable, global_dc, input_location, and line_table.

◆ pedwarn() [1/2]

bool pedwarn ( location_t location,
diagnostic_option_id option_id,
const char * gmsgid,
... )
A "pedantic" warning at LOCATION: issues a warning unless
-pedantic-errors was given on the command line, in which case it
issues an error.  Use this for diagnostics required by the relevant
language standard, if you have chosen not to make them errors.

Note that these diagnostics are issued independent of the setting
of the -Wpedantic command-line switch.  To get a warning enabled
only with that switch, use either "if (pedantic) pedwarn
(OPT_Wpedantic,...)" or just "pedwarn (OPT_Wpedantic,..)".  To get a
pedwarn independently of the -Wpedantic switch use "pedwarn (0,...)".

Returns true if the warning was printed, false if it was inhibited.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.

◆ pedwarn() [2/2]

bool pedwarn ( rich_location * richloc,
diagnostic_option_id option_id,
const char * gmsgid,
... )
Same as pedwarn above, but using RICHLOC.   

References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.

◆ permerror() [1/2]

bool permerror ( location_t location,
const char * gmsgid,
... )
A "permissive" error at LOCATION: issues an error unless
-fpermissive was given on the command line, in which case it issues
a warning.  Use this for things that really should be errors but we
want to support legacy code.

Returns true if the warning was printed, false if it was inhibited.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.

◆ permerror() [2/2]

bool permerror ( rich_location * richloc,
const char * gmsgid,
... )
Same as "permerror" above, but at RICHLOC.   

References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.

◆ permerror_opt() [1/2]

bool permerror_opt ( location_t location,
diagnostic_option_id option_id,
const char * gmsgid,
... )
Similar to the above, but controlled by a flag other than -fpermissive.
As above, an error by default or a warning with -fpermissive, but this
diagnostic can also be downgraded by -Wno-error=opt.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.

◆ permerror_opt() [2/2]

bool permerror_opt ( rich_location * richloc,
diagnostic_option_id option_id,
const char * gmsgid,
... )
Same as "permerror" above, but at RICHLOC.   

References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.

◆ seen_error()

◆ sorry()

void sorry ( const char * gmsgid,
... )
"Sorry, not implemented."  Use for a language feature which is
required by the relevant specification but not implemented by GCC.
An object file will not be produced.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, input_location, and line_table.

◆ sorry_at()

void sorry_at ( location_t loc,
const char * gmsgid,
... )
Same as above, but use location LOC instead of input_location.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.

◆ verbatim()

void verbatim ( const char * gmsgid,
... )
Standard error reporting routines in increasing order of severity.   
Text to be emitted verbatim to the error message stream; this
produces no prefix and disables line-wrapping.  Use rarely.
It is ignored for machine-readable output formats.   

References _, ap, errno, global_dc, and diagnostic_context::report_verbatim().

◆ warning()

bool warning ( diagnostic_option_id option_id,
const char * gmsgid,
... )
A warning at INPUT_LOCATION.  Use this for code which is correct according
to the relevant language specification but is likely to be buggy anyway.
Returns true if the warning was printed, false if it was inhibited.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, input_location, and line_table.

◆ warning_at() [1/2]

bool warning_at ( location_t location,
diagnostic_option_id option_id,
const char * gmsgid,
... )
A warning at LOCATION.  Use this for code which is correct according to the
relevant language specification but is likely to be buggy anyway.
Returns true if the warning was printed, false if it was inhibited.   

References ap, diagnostic_context::diagnostic_impl(), global_dc, and line_table.

◆ warning_at() [2/2]

bool warning_at ( rich_location * richloc,
diagnostic_option_id option_id,
const char * gmsgid,
... )
Same as "warning at" above, but using RICHLOC.   

References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.

◆ warning_meta()

bool warning_meta ( rich_location * richloc,
const diagnostic_metadata & metadata,
diagnostic_option_id option_id,
const char * gmsgid,
... )
Same as "warning at" above, but using METADATA.   

References ap, diagnostic_context::diagnostic_impl(), gcc_assert, and global_dc.

◆ warning_n() [1/2]

bool warning_n ( location_t location,
diagnostic_option_id option_id,
unsigned HOST_WIDE_INT n,
const char * singular_gmsgid,
const char * plural_gmsgid,
... )
A warning at LOCATION.  Use this for code which is correct according to the
relevant language specification but is likely to be buggy anyway.
Returns true if the warning was printed, false if it was inhibited.   

References ap, diagnostic_context::diagnostic_n_impl(), global_dc, and line_table.

◆ warning_n() [2/2]

bool warning_n ( rich_location * richloc,
diagnostic_option_id option_id,
unsigned HOST_WIDE_INT n,
const char * singular_gmsgid,
const char * plural_gmsgid,
... )
Same as warning_n plural variant below, but using RICHLOC.   

References ap, diagnostic_context::diagnostic_n_impl(), gcc_assert, and global_dc.

Variable Documentation

◆ global_dc

This diagnostic_context is used by front-ends that directly output
diagnostic messages without going through `error', `warning',
and similar functions.   

Referenced by gcc_rich_location::add_fixit_insert_formatted(), announce_function(), attr_access::array_as_string(), asm_show_source(), auto_diagnostic_group::auto_diagnostic_group(), auto_diagnostic_nesting_level::auto_diagnostic_nesting_level(), auto_override_urlifier::auto_override_urlifier(), diagnostic_for_asm(), do_self_spec(), driver_handle_option(), emit_diagnostic(), emit_diagnostic(), emit_diagnostic_valist(), emit_diagnostic_valist_meta(), format_string_diagnostic_t::emit_warning_n_va(), error(), error_at(), error_at(), error_meta(), error_n(), escaped_string::escape(), fancy_abort(), fatal_error(), driver::finalize(), fnotice(), general_init(), driver::global_initializations(), inform(), inform(), inform_n(), init_asm_output(), init_options_once(), internal_error(), internal_error_function(), internal_error_no_backtrace(), lang_handle_option(), main(), main(), main(), toplev::main(), option_unspecified_p(), pedwarn(), pedwarn(), permerror(), permerror(), permerror_opt(), permerror_opt(), print_lto_docs_link(), process_command(), process_options(), run_gcc(), sorry(), sorry_at(), target_handle_option(), tree_dump_pretty_printer::tree_dump_pretty_printer(), verbatim(), warning(), warning_at(), warning_at(), warning_enabled_at(), warning_meta(), warning_n(), warning_n(), auto_diagnostic_group::~auto_diagnostic_group(), auto_diagnostic_nesting_level::~auto_diagnostic_nesting_level(), and auto_override_urlifier::~auto_override_urlifier().

◆ global_diagnostic_context

diagnostic_context global_diagnostic_context
static
Language-independent diagnostic subroutines that implicitly use global_dc.
   Copyright (C) 1999-2024 Free Software Foundation, Inc.
   Contributed by Gabriel Dos Reis <gdr@codesourcery.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
This file implements the parts of the language independent aspect
of diagnostic messages that implicitly use global_dc.   
A diagnostic_context surrogate for stderr.