aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-09-02 09:20:09 -0600
committerMartin Sebor <msebor@redhat.com>2021-09-02 09:20:09 -0600
commit9695e1c23be5b5c55d572ced152897313ddb96ae (patch)
treefa5ec855dd296b487abc5e72732607076968f5e8
parent5960477a432c433392832a3765a96105e4f73a80 (diff)
downloadgcc-9695e1c23be5b5c55d572ced152897313ddb96ae.zip
gcc-9695e1c23be5b5c55d572ced152897313ddb96ae.tar.gz
gcc-9695e1c23be5b5c55d572ced152897313ddb96ae.tar.bz2
Improve -Wuninitialized note location.
Related: PR tree-optimization/17506 - warning about uninitialized variable points to wrong location PR testsuite/37182 - Revision 139286 caused gcc.dg/pr17506.c and gcc.dg/uninit-15.c gcc/ChangeLog: PR tree-optimization/17506 PR testsuite/37182 * tree-ssa-uninit.c (warn_uninit): Remove conditional guarding note. gcc/testsuite/ChangeLog: PR tree-optimization/17506 PR testsuite/37182 * gcc.dg/diagnostic-tree-expr-ranges-2.c: Add expected output. * gcc.dg/uninit-15-O0.c: Remove xfail. * gcc.dg/uninit-15.c: Same.
-rw-r--r--gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges-2.c26
-rw-r--r--gcc/testsuite/gcc.dg/uninit-15-O0.c2
-rw-r--r--gcc/testsuite/gcc.dg/uninit-15.c2
-rw-r--r--gcc/tree-ssa-uninit.c9
4 files changed, 18 insertions, 21 deletions
diff --git a/gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges-2.c b/gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges-2.c
index 302e233..1cbcad5 100644
--- a/gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges-2.c
+++ b/gcc/testsuite/gcc.dg/diagnostic-tree-expr-ranges-2.c
@@ -3,21 +3,25 @@
int test_uninit_1 (void)
{
- int result;
- return result; /* { dg-warning "uninitialized" } */
-/* { dg-begin-multiline-output "" }
- return result;
- ^~~~~~
+ int result_1; /* { dg-message "declared here" } */
+ return result_1; /* { dg-warning "uninitialized" } */
+ /* { dg-begin-multiline-output "" }
+ return result_1;
+ ^~~~~~~~
+ int result_1;
+ ^~~~~~~~
{ dg-end-multiline-output "" } */
}
int test_uninit_2 (void)
{
- int result;
- result += 3; /* { dg-warning "uninitialized" } */
-/* { dg-begin-multiline-output "" }
- result += 3;
- ~~~~~~~^~~~
+ int result_2; /* { dg-message "declared here" } */
+ result_2 += 3; /* { dg-warning "uninitialized" } */
+ /* { dg-begin-multiline-output "" }
+ result_2 += 3;
+ ~~~~~~~~~^~~~
+ int result_2;
+ ^~~~~~~~
{ dg-end-multiline-output "" } */
- return result;
+ return result_2;
}
diff --git a/gcc/testsuite/gcc.dg/uninit-15-O0.c b/gcc/testsuite/gcc.dg/uninit-15-O0.c
index 36d9634..1ddddee 100644
--- a/gcc/testsuite/gcc.dg/uninit-15-O0.c
+++ b/gcc/testsuite/gcc.dg/uninit-15-O0.c
@@ -14,7 +14,7 @@ void baz();
void bar()
{
- int j; /* { dg-message "was declared here" {} { xfail *-*-* } } */
+ int j; /* { dg-message "declared here" } */
for (; foo(j); ++j) /* { dg-warning "is used uninitialized" } */
baz();
}
diff --git a/gcc/testsuite/gcc.dg/uninit-15.c b/gcc/testsuite/gcc.dg/uninit-15.c
index 85cb116..7352662 100644
--- a/gcc/testsuite/gcc.dg/uninit-15.c
+++ b/gcc/testsuite/gcc.dg/uninit-15.c
@@ -20,7 +20,7 @@ void baz (void);
void
bar (void)
{
- int j; /* { dg-message "note: 'j' was declared here" "" { xfail *-*-* } } */
+ int j; /* { dg-message "note: 'j' was declared here" } */
for (; foo (j); ++j) /* { dg-warning "'j' is used uninitialized" } */
baz ();
}
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 394dbf4..cb6d114 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -206,14 +206,7 @@ warn_uninit (opt_code opt, tree t, tree var, const char *gmsgid,
if (location == var_loc)
return;
- location_t cfun_loc = DECL_SOURCE_LOCATION (cfun->decl);
- expanded_location xloc = expand_location (location);
- expanded_location floc = expand_location (cfun_loc);
- if (xloc.file != floc.file
- || linemap_location_before_p (line_table, location, cfun_loc)
- || linemap_location_before_p (line_table, cfun->function_end_locus,
- location))
- inform (var_loc, "%qD was declared here", var);
+ inform (var_loc, "%qD was declared here", var);
}
struct check_defs_data