diagnostic-core.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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-2019 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. /* RAII-style class for grouping related diagnostics. */
  32. class auto_diagnostic_group
  33. {
  34. public:
  35. auto_diagnostic_group ();
  36. ~auto_diagnostic_group ();
  37. };
  38. extern const char *progname;
  39. extern const char *trim_filename (const char *);
  40. /* If we haven't already defined a front-end-specific diagnostics
  41. style, use the generic one. */
  42. #ifndef GCC_DIAG_STYLE
  43. #define GCC_DIAG_STYLE __gcc_tdiag__
  44. #endif
  45. /* None of these functions are suitable for ATTRIBUTE_PRINTF, because
  46. each language front end can extend them with its own set of format
  47. specifiers. We must use custom format checks. */
  48. #if (CHECKING_P && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
  49. #define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
  50. #else
  51. #define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
  52. #endif
  53. extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
  54. ATTRIBUTE_NORETURN;
  55. extern void internal_error_no_backtrace (const char *, ...)
  56. ATTRIBUTE_GCC_DIAG(1,2) ATTRIBUTE_NORETURN;
  57. /* Pass one of the OPT_W* from options.h as the first parameter. */
  58. extern bool warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
  59. extern bool warning_n (location_t, int, unsigned HOST_WIDE_INT,
  60. const char *, const char *, ...)
  61. ATTRIBUTE_GCC_DIAG(4,6) ATTRIBUTE_GCC_DIAG(5,6);
  62. extern bool warning_n (rich_location *, int, unsigned HOST_WIDE_INT,
  63. const char *, const char *, ...)
  64. ATTRIBUTE_GCC_DIAG(4, 6) ATTRIBUTE_GCC_DIAG(5, 6);
  65. extern bool warning_at (location_t, int, const char *, ...)
  66. ATTRIBUTE_GCC_DIAG(3,4);
  67. extern bool warning_at (rich_location *, int, const char *, ...)
  68. ATTRIBUTE_GCC_DIAG(3,4);
  69. extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
  70. extern void error_n (location_t, unsigned HOST_WIDE_INT, const char *,
  71. const char *, ...)
  72. ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
  73. extern void error_at (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
  74. extern void error_at (rich_location *, const char *, ...)
  75. ATTRIBUTE_GCC_DIAG(2,3);
  76. extern void fatal_error (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3)
  77. ATTRIBUTE_NORETURN;
  78. /* Pass one of the OPT_W* from options.h as the second parameter. */
  79. extern bool pedwarn (location_t, int, const char *, ...)
  80. ATTRIBUTE_GCC_DIAG(3,4);
  81. extern bool pedwarn (rich_location *, int, const char *, ...)
  82. ATTRIBUTE_GCC_DIAG(3,4);
  83. extern bool permerror (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
  84. extern bool permerror (rich_location *, const char *,
  85. ...) ATTRIBUTE_GCC_DIAG(2,3);
  86. extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
  87. extern void sorry_at (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
  88. extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
  89. extern void inform (rich_location *, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
  90. extern void inform_n (location_t, unsigned HOST_WIDE_INT, const char *,
  91. const char *, ...)
  92. ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
  93. extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
  94. extern bool emit_diagnostic (diagnostic_t, location_t, int,
  95. const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
  96. extern bool emit_diagnostic (diagnostic_t, rich_location *, int,
  97. const char *, ...) ATTRIBUTE_GCC_DIAG(4,5);
  98. extern bool emit_diagnostic_valist (diagnostic_t, location_t, int, const char *,
  99. va_list *) ATTRIBUTE_GCC_DIAG (4,0);
  100. extern bool seen_error (void);
  101. #ifdef BUFSIZ
  102. /* N.B. Unlike all the others, fnotice is just gettext+fprintf, and
  103. therefore it can have ATTRIBUTE_PRINTF. */
  104. extern void fnotice (FILE *, const char *, ...)
  105. ATTRIBUTE_PRINTF_2;
  106. #endif
  107. #endif /* ! GCC_DIAGNOSTIC_CORE_H */