From: Nicholas Guriev Date: Thu, 12 Nov 2020 13:59:35 +0000 (-0500) Subject: Specify reason of -Winvalid-pch warning X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cb808c583de59ea568fd240144cd9db07272f45e;p=gcc.git Specify reason of -Winvalid-pch warning gcc/c-family PR pch/86674 * c-pch.c (c_common_valid_pch): Use cpp_warning with CPP_W_INVALID_PCH reason to fix -Werror=invalid-pch and -Wno-error=invalid-pch switches. libcpp PR pch/86674 * files.c (_cpp_find_file): Use CPP_DL_NOTE not CPP_DL_ERROR in call to cpp_error. --- diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c index a2292f46a7d..9c0bd0b631d 100644 --- a/gcc/c-family/c-pch.c +++ b/gcc/c-family/c-pch.c @@ -211,8 +211,7 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) fatal_error (input_location, "cannot read %s: %m", name); else if (sizeread != IDENT_LENGTH + 16) { - if (cpp_get_options (pfile)->warn_invalid_pch) - cpp_error (pfile, CPP_DL_WARNING, "%s: too short to be a PCH file", + cpp_warning (pfile, CPP_W_INVALID_PCH, "%s: too short to be a PCH file", name); return 2; } @@ -220,27 +219,22 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) pch_ident = get_ident(); if (memcmp (ident, pch_ident, IDENT_LENGTH) != 0) { - if (cpp_get_options (pfile)->warn_invalid_pch) - { - if (memcmp (ident, pch_ident, 5) == 0) - /* It's a PCH, for the right language, but has the wrong version. - */ - cpp_error (pfile, CPP_DL_WARNING, + if (memcmp (ident, pch_ident, 5) == 0) + /* It's a PCH, for the right language, but has the wrong version. */ + cpp_warning (pfile, CPP_W_INVALID_PCH, "%s: not compatible with this GCC version", name); - else if (memcmp (ident, pch_ident, 4) == 0) - /* It's a PCH for the wrong language. */ - cpp_error (pfile, CPP_DL_WARNING, "%s: not for %s", name, + else if (memcmp (ident, pch_ident, 4) == 0) + /* It's a PCH for the wrong language. */ + cpp_warning (pfile, CPP_W_INVALID_PCH, "%s: not for %s", name, lang_hooks.name); - else - /* Not any kind of PCH. */ - cpp_error (pfile, CPP_DL_WARNING, "%s: not a PCH file", name); - } + else + /* Not any kind of PCH. */ + cpp_warning (pfile, CPP_W_INVALID_PCH, "%s: not a PCH file", name); return 2; } if (memcmp (ident + IDENT_LENGTH, executable_checksum, 16) != 0) { - if (cpp_get_options (pfile)->warn_invalid_pch) - cpp_error (pfile, CPP_DL_WARNING, + cpp_warning (pfile, CPP_W_INVALID_PCH, "%s: created by a different GCC executable", name); return 2; } @@ -257,8 +251,7 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) if (v.debug_info_type != write_symbols && write_symbols != NO_DEBUG) { - if (cpp_get_options (pfile)->warn_invalid_pch) - cpp_error (pfile, CPP_DL_WARNING, + cpp_warning (pfile, CPP_W_INVALID_PCH, "%s: created with -g%s, but used with -g%s", name, debug_type_names[v.debug_info_type], debug_type_names[write_symbols]); @@ -271,8 +264,7 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) for (i = 0; i < MATCH_SIZE; i++) if (*pch_matching[i].flag_var != v.match[i]) { - if (cpp_get_options (pfile)->warn_invalid_pch) - cpp_error (pfile, CPP_DL_WARNING, + cpp_warning (pfile, CPP_W_INVALID_PCH, "%s: settings for %s do not match", name, pch_matching[i].flag_name); return 2; @@ -287,8 +279,7 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) check one function. */ if (v.pch_init != &pch_init) { - if (cpp_get_options (pfile)->warn_invalid_pch) - cpp_error (pfile, CPP_DL_WARNING, + cpp_warning (pfile, CPP_W_INVALID_PCH, "%s: had text segment at different address", name); return 2; } @@ -305,8 +296,7 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) free (this_file_data); if (msg != NULL) { - if (cpp_get_options (pfile)->warn_invalid_pch) - cpp_error (pfile, CPP_DL_WARNING, "%s: %s", name, msg); + cpp_warning (pfile, CPP_W_INVALID_PCH, "%s: %s", name, msg); return 2; } } diff --git a/libcpp/files.c b/libcpp/files.c index 5af41364d0a..d73177aa1ee 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -571,7 +571,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, "one or more PCH files were found," " but they were invalid"); if (!cpp_get_options (pfile)->warn_invalid_pch) - cpp_error (pfile, CPP_DL_ERROR, + cpp_error (pfile, CPP_DL_NOTE, "use -Winvalid-pch for more information"); }