GCC Middle and Back End API Reference
diagnostic-core.h
Go to the documentation of this file.
1/* Declarations of core diagnostic functionality for code that does
2 not need to deal with diagnostic contexts or diagnostic info
3 structures.
4 Copyright (C) 1998-2024 Free Software Foundation, Inc.
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 3, or (at your option) any later
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
21
22#ifndef GCC_DIAGNOSTIC_CORE_H
23#define GCC_DIAGNOSTIC_CORE_H
24
25#include "bversion.h"
26
27/* Constants used to discriminate diagnostics. */
28typedef enum
29{
30#define DEFINE_DIAGNOSTIC_KIND(K, msgid, C) K,
31#include "diagnostic.def"
32#undef DEFINE_DIAGNOSTIC_KIND
34 /* This is used for tagging pragma pops in the diagnostic
35 classification history chain. */
37 /* This is used internally to note that a diagnostic is enabled
38 without mandating any specific type. */
41
42/* RAII-style class for grouping related diagnostics. */
43
50
51/* Forward decl. */
52class diagnostic_metadata; /* See diagnostic-metadata.h. */
53
54extern const char *progname;
55
56extern const char *trim_filename (const char *);
57
58/* If we haven't already defined a front-end-specific diagnostics
59 style, use the generic one. */
60#ifndef GCC_DIAG_STYLE
61#define GCC_DIAG_STYLE __gcc_tdiag__
62#endif
63/* None of these functions are suitable for ATTRIBUTE_PRINTF, because
64 each language front end can extend them with its own set of format
65 specifiers. We must use custom format checks. */
66#if (CHECKING_P && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
67#define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
68#else
69#define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
70#endif
71extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
75/* Pass one of the OPT_W* from options.h as the first parameter. */
76extern bool warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
78 const char *, const char *, ...)
80extern bool warning_n (rich_location *, int, unsigned HOST_WIDE_INT,
81 const char *, const char *, ...)
83extern bool warning_at (location_t, int, const char *, ...)
85extern bool warning_at (rich_location *, int, const char *, ...)
87extern bool warning_meta (rich_location *,
89 const char *, ...)
91extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
93 const char *, ...)
96extern void error_at (rich_location *, const char *, ...)
98extern void error_meta (rich_location *, const diagnostic_metadata &,
99 const char *, ...)
103/* Pass one of the OPT_W* from options.h as the second parameter. */
104extern bool pedwarn (location_t, int, const char *, ...)
106extern bool pedwarn (rich_location *, int, const char *, ...)
109extern bool permerror (rich_location *, const char *,
110 ...) ATTRIBUTE_GCC_DIAG(2,3);
111extern bool permerror_opt (location_t, int, const char *, ...)
113extern bool permerror_opt (rich_location *, int, const char *,
114 ...) ATTRIBUTE_GCC_DIAG(3,4);
115extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
118extern void inform (rich_location *, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
120 const char *, ...)
122extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
124 const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
125extern bool emit_diagnostic (diagnostic_t, rich_location *, int,
126 const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
130 rich_location *,
132 int,
133 const char *,
135extern bool seen_error (void);
136
137#ifdef BUFSIZ
138 /* N.B. Unlike all the others, fnotice is just gettext+fprintf, and
139 therefore it can have ATTRIBUTE_PRINTF. */
140extern void fnotice (FILE *, const char *, ...)
142#endif
143
144#endif /* ! GCC_DIAGNOSTIC_CORE_H */
Definition diagnostic-core.h:45
~auto_diagnostic_group()
Definition diagnostic.cc:2390
auto_diagnostic_group()
Definition diagnostic.cc:2383
Definition diagnostic-metadata.h:33
bool pedwarn(location_t, int, const char *,...) ATTRIBUTE_GCC_DIAG(3
bool bool bool bool bool bool void void sorry_at(location_t, const char *,...) ATTRIBUTE_GCC_DIAG(2
void internal_error(const char *,...) ATTRIBUTE_GCC_DIAG(1
void internal_error_no_backtrace(const char *,...) ATTRIBUTE_GCC_DIAG(1
bool bool bool void void error_n(location_t, unsigned HOST_WIDE_INT, const char *, const char *,...) ATTRIBUTE_GCC_DIAG(3
void bool bool bool emit_diagnostic_valist(diagnostic_t, location_t, int, const char *, va_list *) ATTRIBUTE_GCC_DIAG(4
const char * trim_filename(const char *)
Definition diagnostic.cc:1682
bool warning(int, const char *,...) ATTRIBUTE_GCC_DIAG(2
void void void void fatal_error(location_t, const char *,...) ATTRIBUTE_GCC_DIAG(2
void verbatim(const char *,...) ATTRIBUTE_GCC_DIAG(1
bool warning_at(location_t, int, const char *,...) ATTRIBUTE_GCC_DIAG(3
void bool bool bool bool emit_diagnostic_valist_meta(diagnostic_t, rich_location *, const diagnostic_metadata *, int, const char *, va_list *) ATTRIBUTE_GCC_DIAG(5
bool bool bool void error(const char *,...) ATTRIBUTE_GCC_DIAG(1
void bool emit_diagnostic(diagnostic_t, location_t, int, const char *,...) ATTRIBUTE_GCC_DIAG(4
void ATTRIBUTE_NORETURN
Definition diagnostic-core.h:72
void bool bool bool bool bool seen_error(void)
Definition diagnostic.cc:2203
bool bool warning_n(location_t, int, unsigned HOST_WIDE_INT, const char *, const char *,...) ATTRIBUTE_GCC_DIAG(4
bool bool bool warning_meta(rich_location *, const diagnostic_metadata &, int, const char *,...) ATTRIBUTE_GCC_DIAG(4
bool bool bool bool bool bool void sorry(const char *,...) ATTRIBUTE_GCC_DIAG(1
bool bool bool permerror(location_t, const char *,...) ATTRIBUTE_GCC_DIAG(2
void void void error_meta(rich_location *, const diagnostic_metadata &, const char *,...) ATTRIBUTE_GCC_DIAG(3
const char * progname
Definition diagnostic.cc:81
diagnostic_t
Definition diagnostic-core.h:29
@ DK_LAST_DIAGNOSTIC_KIND
Definition diagnostic-core.h:33
@ DK_ANY
Definition diagnostic-core.h:39
@ DK_POP
Definition diagnostic-core.h:36
bool bool bool bool bool permerror_opt(location_t, int, const char *,...) ATTRIBUTE_GCC_DIAG(3
bool bool bool bool bool bool void void void void void inform_n(location_t, unsigned HOST_WIDE_INT, const char *, const char *,...) ATTRIBUTE_GCC_DIAG(3
#define ATTRIBUTE_GCC_DIAG(m, n)
Definition diagnostic-core.h:67
bool bool bool bool bool bool void void void inform(location_t, const char *,...) ATTRIBUTE_GCC_DIAG(2
void error_at(location_t, const char *,...) ATTRIBUTE_GCC_DIAG(2
void fnotice(FILE *file, const char *cmsgid,...)
Definition diagnostic.cc:2273
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184