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.
This commit is contained in:
Nicholas Guriev 2020-11-12 08:59:35 -05:00 committed by Jeff Law
parent 071a31a533
commit cb808c583d
2 changed files with 16 additions and 26 deletions

View File

@ -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;
}
}

View File

@ -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");
}