diagnostic-core.h 3.8 KB

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