diagnostic-core.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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-2018 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 "bversion.h"
  20. /* Constants used to discriminate diagnostics. */
  21. typedef enum
  22. {
  23. #define DEFINE_DIAGNOSTIC_KIND(K, msgid, C) K,
  24. #include "diagnostic.def"
  25. #undef DEFINE_DIAGNOSTIC_KIND
  26. DK_LAST_DIAGNOSTIC_KIND,
  27. /* This is used for tagging pragma pops in the diagnostic
  28. classification history chain. */
  29. DK_POP
  30. } diagnostic_t;
  31. extern const char *progname;
  32. extern const char *trim_filename (const char *);
  33. /* If we haven't already defined a front-end-specific diagnostics
  34. style, use the generic one. */
  35. #ifndef GCC_DIAG_STYLE
  36. #define GCC_DIAG_STYLE __gcc_tdiag__
  37. #endif
  38. /* None of these functions are suitable for ATTRIBUTE_PRINTF, because
  39. each language front end can extend them with its own set of format
  40. specifiers. We must use custom format checks. */
  41. #if (CHECKING_P && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
  42. #define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
  43. #else
  44. #define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
  45. #endif
  46. extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
  47. ATTRIBUTE_NORETURN;
  48. extern void internal_error_no_backtrace (const char *, ...)
  49. ATTRIBUTE_GCC_DIAG(1,2) ATTRIBUTE_NORETURN;
  50. /* Pass one of the OPT_W* from options.h as the first parameter. */
  51. extern bool warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
  52. extern bool warning_n (location_t, int, unsigned HOST_WIDE_INT,
  53. const char *, const char *, ...)
  54. ATTRIBUTE_GCC_DIAG(4,6) ATTRIBUTE_GCC_DIAG(5,6);
  55. extern bool warning_n (rich_location *, int, unsigned HOST_WIDE_INT,
  56. const char *, const char *, ...)
  57. ATTRIBUTE_GCC_DIAG(4, 6) ATTRIBUTE_GCC_DIAG(5, 6);
  58. extern bool warning_at (location_t, int, const char *, ...)
  59. ATTRIBUTE_GCC_DIAG(3,4);
  60. extern bool warning_at (rich_location *, int, const char *, ...)
  61. ATTRIBUTE_GCC_DIAG(3,4);
  62. extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
  63. extern void error_n (location_t, unsigned HOST_WIDE_INT, const char *,
  64. const char *, ...)
  65. ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
  66. extern void error_at (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
  67. extern void error_at (rich_location *, const char *, ...)
  68. ATTRIBUTE_GCC_DIAG(2,3);
  69. extern void fatal_error (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3)
  70. ATTRIBUTE_NORETURN;
  71. /* Pass one of the OPT_W* from options.h as the second parameter. */
  72. extern bool pedwarn (location_t, int, const char *, ...)
  73. ATTRIBUTE_GCC_DIAG(3,4);
  74. extern bool pedwarn (rich_location *, int, const char *, ...)
  75. ATTRIBUTE_GCC_DIAG(3,4);
  76. extern bool permerror (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
  77. extern bool permerror (rich_location *, const char *,
  78. ...) ATTRIBUTE_GCC_DIAG(2,3);
  79. extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
  80. extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
  81. extern void inform (rich_location *, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
  82. extern void inform_n (location_t, unsigned HOST_WIDE_INT, const char *,
  83. const char *, ...)
  84. ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
  85. extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
  86. extern bool emit_diagnostic (diagnostic_t, location_t, int,
  87. const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
  88. extern bool emit_diagnostic_valist (diagnostic_t, location_t, int, const char *,
  89. va_list *) ATTRIBUTE_GCC_DIAG (4,0);
  90. extern bool seen_error (void);
  91. #ifdef BUFSIZ
  92. /* N.B. Unlike all the others, fnotice is just gettext+fprintf, and
  93. therefore it can have ATTRIBUTE_PRINTF. */
  94. extern void fnotice (FILE *, const char *, ...)
  95. ATTRIBUTE_PRINTF_2;
  96. #endif
  97. #endif /* ! GCC_DIAGNOSTIC_CORE_H */