aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2018-10-09 23:37:19 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2018-10-09 23:37:19 +0000
commitc24300baea50482b6788041fbac9a6f197c490fc (patch)
treed3e437990f8267770cb8b4857529ff0c2c7ab49e /libcpp
parent5abdb369eb2f38272bb8ee2ea0488194942c7cff (diff)
downloadgcc-c24300baea50482b6788041fbac9a6f197c490fc.zip
gcc-c24300baea50482b6788041fbac9a6f197c490fc.tar.gz
gcc-c24300baea50482b6788041fbac9a6f197c490fc.tar.bz2
Cleanup of libcpp diagnostic callbacks
This patch renames the "error" callback within libcpp to "diagnostic", and uses the pair of enums in cpplib.h, rather than passing two different kinds of "int" around. gcc/c-family/ChangeLog: * c-common.c (c_option_controlling_cpp_error): Rename to... (c_option_controlling_cpp_diagnostic): ...this, and convert "reason" from int to enum. (c_cpp_error): Rename to... (c_cpp_diagnostic): ...this, converting level and reason to enums. * c-common.h (c_cpp_error): Rename to... (c_cpp_diagnostic): ...this, converting level and reason to enums. * c-opts.c (c_common_init_options): Update for renaming. gcc/fortran/ChangeLog: * cpp.c (gfc_cpp_init_0): Update for renamings. (cb_cpp_error): Rename to... (cb_cpp_diagnostic): ...this, converting level and reason to enums. gcc/ChangeLog: * genmatch.c (error_cb): Rename to... (diagnostic_cb): ...this, converting int params to enums. (fatal_at): Update for renaming. (warning_at): Likewise. (main): Likewise. * input.c (selftest::ebcdic_execution_charset::apply): Update for renaming of... (selftest::ebcdic_execution_charset::on_error): ...this, renaming to... (selftest::ebcdic_execution_charset::on_diagnostic): ...this, converting level and reason to enums. (class selftest::lexer_error_sink): Rename to... (class selftest::lexer_test_options): ...this, renaming field "m_errors" to "m_diagnostics". (selftest::lexer_test_options::apply): Update for renaming of... (selftest::lexer_test_options::on_error): ...this, renaming to... (selftest::lexer_test_options::on_diagnostic): ...this converting level and reason to enums. (selftest::test_lexer_string_locations_raw_string_unterminated): Update for renamings. * opth-gen.awk (struct cpp_reason_option_codes_t): Use enum for "reason". libcpp/ChangeLog: * charset.c (noop_error_cb): Rename to... (noop_diagnostic_cb): ...this, converting params to enums. (cpp_interpret_string_ranges): Update for renaming and enums. * directives.c (check_eol_1): Convert reason to enum. (do_diagnostic): Convert code and reason to enum. (do_error): Use CPP_W_NONE rather than 0. (do_pragma_dependency): Likewise. * errors.c (cpp_diagnostic_at): Convert level and reason to enums. Update for renaming. (cpp_diagnostic): Convert level and reason to enums. (cpp_error): Convert level to enum. (cpp_warning): Convert reason to enums. (cpp_pedwarning): Likewise. (cpp_warning_syshdr): Likewise. (cpp_diagnostic_with_line): Convert level and reason to enums. Update for renaming. (cpp_error_with_line): Convert level to enum. (cpp_warning_with_line): Convert reason to enums. (cpp_pedwarning_with_line): Likewise. (cpp_warning_with_line_syshdr): Likewise. (cpp_error_at): Convert level to enum. (cpp_errno): Likewise. (cpp_errno_filename): Likewise. * include/cpplib.h (enum cpp_diagnostic_level): Name this enum, and move to before struct cpp_callbacks. (enum cpp_warning_reason): Likewise. (cpp_callbacks::diagnostic): Convert params from int to enums. (cpp_error): Convert int param to enum cpp_diagnostic_level. (cpp_warning): Convert int param to enum cpp_warning_reason. (cpp_pedwarning): Likewise. (cpp_warning_syshdr): Likewise. (cpp_errno): Convert int param to enum cpp_diagnostic_level. (cpp_errno_filename): Likewise. (cpp_error_with_line): Likewise. (cpp_warning_with_line): Convert int param to enum cpp_warning_reason. (cpp_pedwarning_with_line): Likewise. (cpp_warning_with_line_syshdr): Likewise. (cpp_error_at): Convert int param to enum cpp_diagnostic_level. * macro.c (create_iso_definition): Convert int to enum. (_cpp_create_definition): Likewise. From-SVN: r264999
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog44
-rw-r--r--libcpp/charset.c30
-rw-r--r--libcpp/directives.c12
-rw-r--r--libcpp/errors.c66
-rw-r--r--libcpp/include/cpplib.h158
-rw-r--r--libcpp/macro.c4
6 files changed, 191 insertions, 123 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index ef96824..6681101 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,47 @@
+2018-10-09 David Malcolm <dmalcolm@redhat.com>
+
+ * charset.c (noop_error_cb): Rename to...
+ (noop_diagnostic_cb): ...this, converting params to enums.
+ (cpp_interpret_string_ranges): Update for renaming and enums.
+ * directives.c (check_eol_1): Convert reason to enum.
+ (do_diagnostic): Convert code and reason to enum.
+ (do_error): Use CPP_W_NONE rather than 0.
+ (do_pragma_dependency): Likewise.
+ * errors.c (cpp_diagnostic_at): Convert level and reason to enums.
+ Update for renaming.
+ (cpp_diagnostic): Convert level and reason to enums.
+ (cpp_error): Convert level to enum.
+ (cpp_warning): Convert reason to enums.
+ (cpp_pedwarning): Likewise.
+ (cpp_warning_syshdr): Likewise.
+ (cpp_diagnostic_with_line): Convert level and reason to enums.
+ Update for renaming.
+ (cpp_error_with_line): Convert level to enum.
+ (cpp_warning_with_line): Convert reason to enums.
+ (cpp_pedwarning_with_line): Likewise.
+ (cpp_warning_with_line_syshdr): Likewise.
+ (cpp_error_at): Convert level to enum.
+ (cpp_errno): Likewise.
+ (cpp_errno_filename): Likewise.
+ * include/cpplib.h (enum cpp_diagnostic_level): Name this enum,
+ and move to before struct cpp_callbacks.
+ (enum cpp_warning_reason): Likewise.
+ (cpp_callbacks::diagnostic): Convert params from int to enums.
+ (cpp_error): Convert int param to enum cpp_diagnostic_level.
+ (cpp_warning): Convert int param to enum cpp_warning_reason.
+ (cpp_pedwarning): Likewise.
+ (cpp_warning_syshdr): Likewise.
+ (cpp_errno): Convert int param to enum cpp_diagnostic_level.
+ (cpp_errno_filename): Likewise.
+ (cpp_error_with_line): Likewise.
+ (cpp_warning_with_line): Convert int param to enum
+ cpp_warning_reason.
+ (cpp_pedwarning_with_line): Likewise.
+ (cpp_warning_with_line_syshdr): Likewise.
+ (cpp_error_at): Convert int param to enum cpp_diagnostic_level.
+ * macro.c (create_iso_definition): Convert int to enum.
+ (_cpp_create_definition): Likewise.
+
2018-09-17 David Malcolm <dmalcolm@redhat.com>
* include/line-map.h (range_label::get_text): Add param
diff --git a/libcpp/charset.c b/libcpp/charset.c
index c6dce0d..36c57a6 100644
--- a/libcpp/charset.c
+++ b/libcpp/charset.c
@@ -1693,13 +1693,14 @@ cpp_interpret_string (cpp_reader *pfile, const cpp_string *from, size_t count,
return cpp_interpret_string_1 (pfile, from, count, to, type, NULL, NULL);
}
-/* A "do nothing" error-handling callback for use by
+/* A "do nothing" diagnostic-handling callback for use by
cpp_interpret_string_ranges, so that it can temporarily suppress
- error-handling. */
+ diagnostic-handling. */
static bool
-noop_error_cb (cpp_reader *, int, int, rich_location *,
- const char *, va_list *)
+noop_diagnostic_cb (cpp_reader *, enum cpp_diagnostic_level,
+ enum cpp_warning_reason, rich_location *,
+ const char *, va_list *)
{
/* no-op. */
return true;
@@ -1737,25 +1738,26 @@ cpp_interpret_string_ranges (cpp_reader *pfile, const cpp_string *from,
return "execution character set != source character set";
/* For on-demand strings we have already lexed the strings, so there
- should be no errors. However, if we have bogus source location
+ should be no diagnostics. However, if we have bogus source location
data (or stringified macro arguments), the attempt to lex the
- strings could fail with an error. Temporarily install an
- error-handler to catch the error, so that it can lead to this call
+ strings could fail with an diagnostic. Temporarily install an
+ diagnostic-handler to catch the diagnostic, so that it can lead to this call
failing, rather than being emitted as a user-visible diagnostic.
- If an error does occur, we should see it via the return value of
+ If an diagnostic does occur, we should see it via the return value of
cpp_interpret_string_1. */
- bool (*saved_error_handler) (cpp_reader *, int, int, rich_location *,
- const char *, va_list *)
+ bool (*saved_diagnostic_handler) (cpp_reader *, enum cpp_diagnostic_level,
+ enum cpp_warning_reason, rich_location *,
+ const char *, va_list *)
ATTRIBUTE_FPTR_PRINTF(5,0);
- saved_error_handler = pfile->cb.error;
- pfile->cb.error = noop_error_cb;
+ saved_diagnostic_handler = pfile->cb.diagnostic;
+ pfile->cb.diagnostic = noop_diagnostic_cb;
bool result = cpp_interpret_string_1 (pfile, from, count, NULL, type,
loc_readers, out);
- /* Restore the saved error-handler. */
- pfile->cb.error = saved_error_handler;
+ /* Restore the saved diagnostic-handler. */
+ pfile->cb.diagnostic = saved_diagnostic_handler;
if (!result)
return "cpp_interpret_string_1 failed";
diff --git a/libcpp/directives.c b/libcpp/directives.c
index f7c460d..9793e6b 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -102,7 +102,8 @@ static const char *parse_include (cpp_reader *, int *, const cpp_token ***,
static void push_conditional (cpp_reader *, int, int, const cpp_hashnode *);
static unsigned int read_flag (cpp_reader *, unsigned int);
static bool strtolinenum (const uchar *, size_t, linenum_type *, bool *);
-static void do_diagnostic (cpp_reader *, int, int, int);
+static void do_diagnostic (cpp_reader *, enum cpp_diagnostic_level code,
+ enum cpp_warning_reason reason, int);
static cpp_hashnode *lex_macro_node (cpp_reader *, bool);
static int undefine_macros (cpp_reader *, cpp_hashnode *, void *);
static void do_include_common (cpp_reader *, enum include_type);
@@ -227,7 +228,7 @@ skip_rest_of_line (cpp_reader *pfile)
/* Helper function for check_oel. */
static void
-check_eol_1 (cpp_reader *pfile, bool expand, int reason)
+check_eol_1 (cpp_reader *pfile, bool expand, enum cpp_warning_reason reason)
{
if (! SEEN_EOL () && (expand
? cpp_get_token (pfile)
@@ -1140,7 +1141,8 @@ _cpp_do_file_change (cpp_reader *pfile, enum lc_reason reason,
/* Report a warning or error detected by the program we are
processing. Use the directive's tokens in the error message. */
static void
-do_diagnostic (cpp_reader *pfile, int code, int reason, int print_dir)
+do_diagnostic (cpp_reader *pfile, enum cpp_diagnostic_level code,
+ enum cpp_warning_reason reason, int print_dir)
{
const unsigned char *dir_name;
unsigned char *line;
@@ -1166,7 +1168,7 @@ do_diagnostic (cpp_reader *pfile, int code, int reason, int print_dir)
static void
do_error (cpp_reader *pfile)
{
- do_diagnostic (pfile, CPP_DL_ERROR, 0, 1);
+ do_diagnostic (pfile, CPP_DL_ERROR, CPP_W_NONE, 1);
}
static void
@@ -1720,7 +1722,7 @@ do_pragma_dependency (cpp_reader *pfile)
if (cpp_get_token (pfile)->type != CPP_EOF)
{
_cpp_backup_tokens (pfile, 1);
- do_diagnostic (pfile, CPP_DL_WARNING, 0, 0);
+ do_diagnostic (pfile, CPP_DL_WARNING, CPP_W_NONE, 0);
}
}
diff --git a/libcpp/errors.c b/libcpp/errors.c
index a68ae98..2268fc4 100644
--- a/libcpp/errors.c
+++ b/libcpp/errors.c
@@ -31,15 +31,15 @@ along with this program; see the file COPYING3. If not see
ATTRIBUTE_FPTR_PRINTF(5,0)
static bool
-cpp_diagnostic_at (cpp_reader * pfile, int level, int reason,
- rich_location *richloc,
+cpp_diagnostic_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
+ enum cpp_warning_reason reason, rich_location *richloc,
const char *msgid, va_list *ap)
{
bool ret;
- if (!pfile->cb.error)
+ if (!pfile->cb.diagnostic)
abort ();
- ret = pfile->cb.error (pfile, level, reason, richloc, _(msgid), ap);
+ ret = pfile->cb.diagnostic (pfile, level, reason, richloc, _(msgid), ap);
return ret;
}
@@ -48,8 +48,9 @@ cpp_diagnostic_at (cpp_reader * pfile, int level, int reason,
ATTRIBUTE_FPTR_PRINTF(4,0)
static bool
-cpp_diagnostic (cpp_reader * pfile, int level, int reason,
- const char *msgid, va_list *ap)
+cpp_diagnostic (cpp_reader * pfile, enum cpp_diagnostic_level level,
+ enum cpp_warning_reason reason,
+ const char *msgid, va_list *ap)
{
source_location src_loc;
@@ -77,7 +78,8 @@ cpp_diagnostic (cpp_reader * pfile, int level, int reason,
/* Print a warning or error, depending on the value of LEVEL. */
bool
-cpp_error (cpp_reader * pfile, int level, const char *msgid, ...)
+cpp_error (cpp_reader * pfile, enum cpp_diagnostic_level level,
+ const char *msgid, ...)
{
va_list ap;
bool ret;
@@ -93,7 +95,8 @@ cpp_error (cpp_reader * pfile, int level, const char *msgid, ...)
/* Print a warning. The warning reason may be given in REASON. */
bool
-cpp_warning (cpp_reader * pfile, int reason, const char *msgid, ...)
+cpp_warning (cpp_reader * pfile, enum cpp_warning_reason reason,
+ const char *msgid, ...)
{
va_list ap;
bool ret;
@@ -109,7 +112,8 @@ cpp_warning (cpp_reader * pfile, int reason, const char *msgid, ...)
/* Print a pedantic warning. The warning reason may be given in REASON. */
bool
-cpp_pedwarning (cpp_reader * pfile, int reason, const char *msgid, ...)
+cpp_pedwarning (cpp_reader * pfile, enum cpp_warning_reason reason,
+ const char *msgid, ...)
{
va_list ap;
bool ret;
@@ -126,7 +130,8 @@ cpp_pedwarning (cpp_reader * pfile, int reason, const char *msgid, ...)
given in REASON. */
bool
-cpp_warning_syshdr (cpp_reader * pfile, int reason, const char *msgid, ...)
+cpp_warning_syshdr (cpp_reader * pfile, enum cpp_warning_reason reason,
+ const char *msgid, ...)
{
va_list ap;
bool ret;
@@ -143,18 +148,19 @@ cpp_warning_syshdr (cpp_reader * pfile, int reason, const char *msgid, ...)
ATTRIBUTE_FPTR_PRINTF(6,0)
static bool
-cpp_diagnostic_with_line (cpp_reader * pfile, int level, int reason,
- source_location src_loc, unsigned int column,
- const char *msgid, va_list *ap)
+cpp_diagnostic_with_line (cpp_reader * pfile, enum cpp_diagnostic_level level,
+ enum cpp_warning_reason reason,
+ source_location src_loc, unsigned int column,
+ const char *msgid, va_list *ap)
{
bool ret;
- if (!pfile->cb.error)
+ if (!pfile->cb.diagnostic)
abort ();
rich_location richloc (pfile->line_table, src_loc);
if (column)
richloc.override_column (column);
- ret = pfile->cb.error (pfile, level, reason, &richloc, _(msgid), ap);
+ ret = pfile->cb.diagnostic (pfile, level, reason, &richloc, _(msgid), ap);
return ret;
}
@@ -162,7 +168,7 @@ cpp_diagnostic_with_line (cpp_reader * pfile, int level, int reason,
/* Print a warning or error, depending on the value of LEVEL. */
bool
-cpp_error_with_line (cpp_reader *pfile, int level,
+cpp_error_with_line (cpp_reader *pfile, enum cpp_diagnostic_level level,
source_location src_loc, unsigned int column,
const char *msgid, ...)
{
@@ -181,7 +187,7 @@ cpp_error_with_line (cpp_reader *pfile, int level,
/* Print a warning. The warning reason may be given in REASON. */
bool
-cpp_warning_with_line (cpp_reader *pfile, int reason,
+cpp_warning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason,
source_location src_loc, unsigned int column,
const char *msgid, ...)
{
@@ -200,9 +206,9 @@ cpp_warning_with_line (cpp_reader *pfile, int reason,
/* Print a pedantic warning. The warning reason may be given in REASON. */
bool
-cpp_pedwarning_with_line (cpp_reader *pfile, int reason,
- source_location src_loc, unsigned int column,
- const char *msgid, ...)
+cpp_pedwarning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason,
+ source_location src_loc, unsigned int column,
+ const char *msgid, ...)
{
va_list ap;
bool ret;
@@ -220,9 +226,9 @@ cpp_pedwarning_with_line (cpp_reader *pfile, int reason,
given in REASON. */
bool
-cpp_warning_with_line_syshdr (cpp_reader *pfile, int reason,
- source_location src_loc, unsigned int column,
- const char *msgid, ...)
+cpp_warning_with_line_syshdr (cpp_reader *pfile, enum cpp_warning_reason reason,
+ source_location src_loc, unsigned int column,
+ const char *msgid, ...)
{
va_list ap;
bool ret;
@@ -240,8 +246,8 @@ cpp_warning_with_line_syshdr (cpp_reader *pfile, int reason,
a column override. */
bool
-cpp_error_at (cpp_reader * pfile, int level, source_location src_loc,
- const char *msgid, ...)
+cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
+ source_location src_loc, const char *msgid, ...)
{
va_list ap;
bool ret;
@@ -260,8 +266,8 @@ cpp_error_at (cpp_reader * pfile, int level, source_location src_loc,
a column override. */
bool
-cpp_error_at (cpp_reader * pfile, int level, rich_location *richloc,
- const char *msgid, ...)
+cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
+ rich_location *richloc, const char *msgid, ...)
{
va_list ap;
bool ret;
@@ -279,7 +285,8 @@ cpp_error_at (cpp_reader * pfile, int level, rich_location *richloc,
information from errno. */
bool
-cpp_errno (cpp_reader *pfile, int level, const char *msgid)
+cpp_errno (cpp_reader *pfile, enum cpp_diagnostic_level level,
+ const char *msgid)
{
return cpp_error (pfile, level, "%s: %s", _(msgid), xstrerror (errno));
}
@@ -289,7 +296,8 @@ cpp_errno (cpp_reader *pfile, int level, const char *msgid)
that is not localized, but "" is replaced with localized "stdout". */
bool
-cpp_errno_filename (cpp_reader *pfile, int level, const char *filename,
+cpp_errno_filename (cpp_reader *pfile, enum cpp_diagnostic_level level,
+ const char *filename,
source_location loc)
{
if (filename[0] == '\0')
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 85aa09f..797cfb9 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -549,6 +549,59 @@ struct cpp_options
bool canonical_system_headers;
};
+/* Diagnostic levels. To get a diagnostic without associating a
+ position in the translation unit with it, use cpp_error_with_line
+ with a line number of zero. */
+
+enum cpp_diagnostic_level {
+ /* Warning, an error with -Werror. */
+ CPP_DL_WARNING = 0,
+ /* Same as CPP_DL_WARNING, except it is not suppressed in system headers. */
+ CPP_DL_WARNING_SYSHDR,
+ /* Warning, an error with -pedantic-errors or -Werror. */
+ CPP_DL_PEDWARN,
+ /* An error. */
+ CPP_DL_ERROR,
+ /* An internal consistency check failed. Prints "internal error: ",
+ otherwise the same as CPP_DL_ERROR. */
+ CPP_DL_ICE,
+ /* An informative note following a warning. */
+ CPP_DL_NOTE,
+ /* A fatal error. */
+ CPP_DL_FATAL
+};
+
+/* Warning reason codes. Use a reason code of CPP_W_NONE for unclassified
+ warnings and diagnostics that are not warnings. */
+
+enum cpp_warning_reason {
+ CPP_W_NONE = 0,
+ CPP_W_DEPRECATED,
+ CPP_W_COMMENTS,
+ CPP_W_MISSING_INCLUDE_DIRS,
+ CPP_W_TRIGRAPHS,
+ CPP_W_MULTICHAR,
+ CPP_W_TRADITIONAL,
+ CPP_W_LONG_LONG,
+ CPP_W_ENDIF_LABELS,
+ CPP_W_NUM_SIGN_CHANGE,
+ CPP_W_VARIADIC_MACROS,
+ CPP_W_BUILTIN_MACRO_REDEFINED,
+ CPP_W_DOLLARS,
+ CPP_W_UNDEF,
+ CPP_W_UNUSED_MACROS,
+ CPP_W_CXX_OPERATOR_NAMES,
+ CPP_W_NORMALIZE,
+ CPP_W_INVALID_PCH,
+ CPP_W_WARNING_DIRECTIVE,
+ CPP_W_LITERAL_SUFFIX,
+ CPP_W_DATE_TIME,
+ CPP_W_PEDANTIC,
+ CPP_W_C90_C99_COMPAT,
+ CPP_W_CXX11_COMPAT,
+ CPP_W_EXPANSION_TO_DEFINED
+};
+
/* Callback for header lookup for HEADER, which is the name of a
source file. It is used as a method of last resort to find headers
that are not otherwise found during the normal include processing.
@@ -586,8 +639,11 @@ struct cpp_callbacks
/* Called to emit a diagnostic. This callback receives the
translated message. */
- bool (*error) (cpp_reader *, int, int, rich_location *,
- const char *, va_list *)
+ bool (*diagnostic) (cpp_reader *,
+ enum cpp_diagnostic_level,
+ enum cpp_warning_reason,
+ rich_location *,
+ const char *, va_list *)
ATTRIBUTE_FPTR_PRINTF(5,0);
/* Callbacks for when a macro is expanded, or tested (whether
@@ -1084,99 +1140,55 @@ extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *,
others assumed clear, to fill out a cpp_num structure. */
cpp_num cpp_num_sign_extend (cpp_num, size_t);
-/* Diagnostic levels. To get a diagnostic without associating a
- position in the translation unit with it, use cpp_error_with_line
- with a line number of zero. */
-
-enum {
- /* Warning, an error with -Werror. */
- CPP_DL_WARNING = 0,
- /* Same as CPP_DL_WARNING, except it is not suppressed in system headers. */
- CPP_DL_WARNING_SYSHDR,
- /* Warning, an error with -pedantic-errors or -Werror. */
- CPP_DL_PEDWARN,
- /* An error. */
- CPP_DL_ERROR,
- /* An internal consistency check failed. Prints "internal error: ",
- otherwise the same as CPP_DL_ERROR. */
- CPP_DL_ICE,
- /* An informative note following a warning. */
- CPP_DL_NOTE,
- /* A fatal error. */
- CPP_DL_FATAL
-};
-
-/* Warning reason codes. Use a reason code of zero for unclassified warnings
- and errors that are not warnings. */
-enum {
- CPP_W_NONE = 0,
- CPP_W_DEPRECATED,
- CPP_W_COMMENTS,
- CPP_W_MISSING_INCLUDE_DIRS,
- CPP_W_TRIGRAPHS,
- CPP_W_MULTICHAR,
- CPP_W_TRADITIONAL,
- CPP_W_LONG_LONG,
- CPP_W_ENDIF_LABELS,
- CPP_W_NUM_SIGN_CHANGE,
- CPP_W_VARIADIC_MACROS,
- CPP_W_BUILTIN_MACRO_REDEFINED,
- CPP_W_DOLLARS,
- CPP_W_UNDEF,
- CPP_W_UNUSED_MACROS,
- CPP_W_CXX_OPERATOR_NAMES,
- CPP_W_NORMALIZE,
- CPP_W_INVALID_PCH,
- CPP_W_WARNING_DIRECTIVE,
- CPP_W_LITERAL_SUFFIX,
- CPP_W_DATE_TIME,
- CPP_W_PEDANTIC,
- CPP_W_C90_C99_COMPAT,
- CPP_W_CXX11_COMPAT,
- CPP_W_EXPANSION_TO_DEFINED
-};
-
/* Output a diagnostic of some kind. */
-extern bool cpp_error (cpp_reader *, int, const char *msgid, ...)
+extern bool cpp_error (cpp_reader *, enum cpp_diagnostic_level,
+ const char *msgid, ...)
ATTRIBUTE_PRINTF_3;
-extern bool cpp_warning (cpp_reader *, int, const char *msgid, ...)
+extern bool cpp_warning (cpp_reader *, enum cpp_warning_reason,
+ const char *msgid, ...)
ATTRIBUTE_PRINTF_3;
-extern bool cpp_pedwarning (cpp_reader *, int, const char *msgid, ...)
+extern bool cpp_pedwarning (cpp_reader *, enum cpp_warning_reason,
+ const char *msgid, ...)
ATTRIBUTE_PRINTF_3;
-extern bool cpp_warning_syshdr (cpp_reader *, int, const char *msgid, ...)
+extern bool cpp_warning_syshdr (cpp_reader *, enum cpp_warning_reason reason,
+ const char *msgid, ...)
ATTRIBUTE_PRINTF_3;
/* Output a diagnostic with "MSGID: " preceding the
error string of errno. No location is printed. */
-extern bool cpp_errno (cpp_reader *, int, const char *msgid);
+extern bool cpp_errno (cpp_reader *, enum cpp_diagnostic_level,
+ const char *msgid);
/* Similarly, but with "FILENAME: " instead of "MSGID: ", where
the filename is not localized. */
-extern bool cpp_errno_filename (cpp_reader *, int, const char *filename,
- source_location loc);
+extern bool cpp_errno_filename (cpp_reader *, enum cpp_diagnostic_level,
+ const char *filename, source_location loc);
/* Same as cpp_error, except additionally specifies a position as a
(translation unit) physical line and physical column. If the line is
zero, then no location is printed. */
-extern bool cpp_error_with_line (cpp_reader *, int, source_location,
- unsigned, const char *msgid, ...)
+extern bool cpp_error_with_line (cpp_reader *, enum cpp_diagnostic_level,
+ source_location, unsigned,
+ const char *msgid, ...)
ATTRIBUTE_PRINTF_5;
-extern bool cpp_warning_with_line (cpp_reader *, int, source_location,
- unsigned, const char *msgid, ...)
+extern bool cpp_warning_with_line (cpp_reader *, enum cpp_warning_reason,
+ source_location, unsigned,
+ const char *msgid, ...)
ATTRIBUTE_PRINTF_5;
-extern bool cpp_pedwarning_with_line (cpp_reader *, int, source_location,
- unsigned, const char *msgid, ...)
+extern bool cpp_pedwarning_with_line (cpp_reader *, enum cpp_warning_reason,
+ source_location, unsigned,
+ const char *msgid, ...)
ATTRIBUTE_PRINTF_5;
-extern bool cpp_warning_with_line_syshdr (cpp_reader *, int, source_location,
- unsigned, const char *msgid, ...)
+extern bool cpp_warning_with_line_syshdr (cpp_reader *, enum cpp_warning_reason,
+ source_location, unsigned,
+ const char *msgid, ...)
ATTRIBUTE_PRINTF_5;
-extern bool cpp_error_at (cpp_reader * pfile, int level,
+extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
source_location src_loc, const char *msgid, ...)
ATTRIBUTE_PRINTF_4;
-extern bool cpp_error_at (cpp_reader * pfile, int level,
- rich_location *richloc, const char *msgid,
- ...)
+extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
+ rich_location *richloc, const char *msgid, ...)
ATTRIBUTE_PRINTF_4;
/* In lex.c */
diff --git a/libcpp/macro.c b/libcpp/macro.c
index 3629e83..073816d 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -3297,7 +3297,7 @@ create_iso_definition (cpp_reader *pfile)
: N_("ISO C99 requires whitespace after the macro name"));
else
{
- int warntype = CPP_DL_WARNING;
+ enum cpp_diagnostic_level warntype = CPP_DL_WARNING;
switch (token->type)
{
case CPP_ATSIGN:
@@ -3512,7 +3512,7 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node)
if (warn_of_redefinition (pfile, node, macro))
{
- const int reason
+ const enum cpp_warning_reason reason
= (cpp_builtin_macro_p (node) && !(node->flags & NODE_WARN))
? CPP_W_BUILTIN_MACRO_REDEFINED : CPP_W_NONE;