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