[go: nahoru, domu]

blob: a9edb0d421d2ceb8941cfb43068767713b8e3553 [file] [log] [blame]
Jing Yu21b2cba2012-04-24 14:08:37 -07001/* 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, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007,
5 2008, 2009, 2010
6 Free Software Foundation, Inc.
7
8This file is part of GCC.
9
10GCC is free software; you can redistribute it and/or modify it under
11the terms of the GNU General Public License as published by the Free
12Software Foundation; either version 3, or (at your option) any later
13version.
14
15GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16WARRANTY; without even the implied warranty of MERCHANTABILITY or
17FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18for more details.
19
20You should have received a copy of the GNU General Public License
21along with GCC; see the file COPYING3. If not see
22<http://www.gnu.org/licenses/>. */
23
24#ifndef GCC_DIAGNOSTIC_CORE_H
25#define GCC_DIAGNOSTIC_CORE_H
26
27#include "input.h"
28#include "bversion.h"
29
30/* Constants used to discriminate diagnostics. */
31typedef enum
32{
33#define DEFINE_DIAGNOSTIC_KIND(K, msgid) K,
34#include "diagnostic.def"
35#undef DEFINE_DIAGNOSTIC_KIND
36 DK_LAST_DIAGNOSTIC_KIND,
37 /* This is used for tagging pragma pops in the diagnostic
38 classification history chain. */
39 DK_POP
40} diagnostic_t;
41
42extern const char *progname;
43
44extern const char *trim_filename (const char *);
45
46/* If we haven't already defined a front-end-specific diagnostics
47 style, use the generic one. */
48#ifndef GCC_DIAG_STYLE
49#define GCC_DIAG_STYLE __gcc_tdiag__
50#endif
51/* None of these functions are suitable for ATTRIBUTE_PRINTF, because
52 each language front end can extend them with its own set of format
53 specifiers. We must use custom format checks. */
54#if (ENABLE_CHECKING && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
55#define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
56#else
57#define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
58#endif
59extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
60 ATTRIBUTE_NORETURN;
61/* Pass one of the OPT_W* from options.h as the first parameter. */
62extern bool warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
63extern bool warning_at (location_t, int, const char *, ...)
64 ATTRIBUTE_GCC_DIAG(3,4);
65extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
66extern void error_n (location_t, int, const char *, const char *, ...)
67 ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
68extern void error_at (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
69extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
70 ATTRIBUTE_NORETURN;
71/* Pass one of the OPT_W* from options.h as the second parameter. */
72extern bool pedwarn (location_t, int, const char *, ...)
73 ATTRIBUTE_GCC_DIAG(3,4);
74extern bool permerror (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
75extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
76extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
77extern void inform_n (location_t, int, const char *, const char *, ...)
78 ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
79extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
80extern bool emit_diagnostic (diagnostic_t, location_t, int,
81 const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
82extern bool seen_error (void);
83
84#ifdef BUFSIZ
85 /* N.B. Unlike all the others, fnotice is just gettext+fprintf, and
86 therefore it can have ATTRIBUTE_PRINTF. */
87extern void fnotice (FILE *, const char *, ...)
88 ATTRIBUTE_PRINTF_2;
89#endif
90
91#endif /* ! GCC_DIAGNOSTIC_CORE_H */