gimple-ssa-warn-access: Fix up asan_test.C -Wdangling-pointer regression [PR104103]
authorJakub Jelinek <jakub@redhat.com>
Wed, 19 Jan 2022 08:28:25 +0000 (09:28 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 19 Jan 2022 08:28:25 +0000 (09:28 +0100)
commit53836c887a05db23ff3b9fc06f64e0ba78810ece
tree796c3f091ff9a2ab19f69038c2cb7e9d09ec5edb
parentb834435c8fa4cb9424787fe3044a49fef7992de8
gimple-ssa-warn-access: Fix up asan_test.C -Wdangling-pointer regression [PR104103]

As reported in the PR or as I've seen since the weekend, asan_test.C fails
because of many warnings like:
gcc/testsuite/g++.dg/asan/asan_test.cc:1157:10: error: using a dangling pointer to an unnamed temporary [-Werror=dangling-pointer=]
gcc/testsuite/g++.dg/asan/asan_test.cc:1157:10: error: using a dangling pointer to an unnamed temporary [-Werror=dangling-pointer=]
gcc/testsuite/g++.dg/asan/asan_test.cc:1162:27: error: using a dangling pointer to an unnamed temporary [-Werror=dangling-pointer=]
...
(lots of them).
There are no dangling pointers though, the warning pass sees:
  some_automatic_var ={v} {CLOBBER};
  .ASAN_MARK (POISON, &some_automatic_var, 8);
and warns on that (both on user vars and on e.g. TARGET_EXPR temporaries).
There is nothing wrong on that, .ASAN_MARK is compiler instrumentation,
which doesn't even touch the variable in any way nor make it escaped.
What it instead does is change bytes in the shadow memory corresponding
to the variable to reflect that the variable is out of scope and make
sure that access to it would be diagnosed at runtime.
So, for all purposes of the -Wdangling-pointer and -Wuse-after-free
warnings, we should ignore this internal call.

2022-01-19  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/104103
* gimple-ssa-warn-access.cc (pass_waccess::check_call): Don't check
.ASAN_MARK calls.
gcc/gimple-ssa-warn-access.cc