Hi.
The patch improves locations of the warning in following way:
sample.c: In function ‘main’:
sample.c:16:1: error: source locations for function ‘main’ have changed, the
profile data may be out of date [-Werror=coverage-mismatch]
16 | }
| ^
sample.c:16:1: error: source locations for function ‘main’ have changed, the
profile data may be out of date [-Werror=coverage-mismatch]
cc1: some warnings being treated as errors
into:
sample.c: In function ‘main’:
sample.c:10:5: error: source locations for function ‘main’ have changed, the
profile data may be out of date [-Werror=coverage-mismatch]
10 | int main()
| ^~~~
sample.c:10:5: error: source locations for function ‘main’ have changed, the
profile data may be out of date [-Werror=coverage-mismatch]
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
Thanks,
Martin
gcc/ChangeLog:
2018-09-12 Martin Liska <[email protected]>
* coverage.c (get_coverage_counts): Use warning_at
with current_function_decl location. Use %qD in warning
message.
---
gcc/coverage.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/gcc/coverage.c b/gcc/coverage.c
index bae6f5cafac..71f2c59e5a7 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -374,12 +374,13 @@ get_coverage_counts (unsigned counter, unsigned expected,
{
static int warned = 0;
bool warning_printed = false;
- tree id = DECL_ASSEMBLER_NAME (current_function_decl);
warning_printed =
- warning_at (input_location, OPT_Wcoverage_mismatch,
- "the control flow of function %qE does not match "
- "its profile data (counter %qs)", id, ctr_names[counter]);
+ warning_at (DECL_SOURCE_LOCATION (current_function_decl),
+ OPT_Wcoverage_mismatch,
+ "the control flow of function %qD does not match "
+ "its profile data (counter %qs)", current_function_decl,
+ ctr_names[counter]);
if (warning_printed && dump_enabled_p ())
{
dump_user_location_t loc
@@ -408,10 +409,11 @@ get_coverage_counts (unsigned counter, unsigned expected,
}
else if (entry->lineno_checksum != lineno_checksum)
{
- warning (OPT_Wcoverage_mismatch,
- "source locations for function %qE have changed,"
- " the profile data may be out of date",
- DECL_ASSEMBLER_NAME (current_function_decl));
+ warning_at (DECL_SOURCE_LOCATION (current_function_decl),
+ OPT_Wcoverage_mismatch,
+ "source locations for function %qD have changed,"
+ " the profile data may be out of date",
+ current_function_decl);
}
if (summary)