]> git.ipfire.org Git - thirdparty/gcc.git/commit
gimple-fold: Preserve location in gimple_fold_builtin_memset
authorJakub Jelinek <jakub@redhat.com>
Fri, 29 Oct 2021 08:20:29 +0000 (10:20 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 29 Oct 2021 08:20:29 +0000 (10:20 +0200)
commitf1ba6a819de6f4aacf9d69725f64496d20edd5a1
tree27bc21a1517537e9c1e2e62e2b30e6aad573e226
parent4cd2a27a1c910421b31fd72dea726d838c1a39e9
gimple-fold: Preserve location in gimple_fold_builtin_memset

As mentioned yesterday, gimple_fold_builtin_memset doesn't preserve
locus which means e.g. the -Wstringop-overflow warnings are emitted as:
In function 'test_max':
cc1: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
The function emits up to 2 new statements, but the latter (asgn) is added
through gsi_replace and therefore the locus is copied over from the call.
But store is emitted before the call and optionally the call removed
afterwards, so locus needs to be copied over manually.

2021-10-29  Jakub Jelinek  <jakub@redhat.com>

* gimple-fold.c (gimple_fold_builtin_memset): Copy over location from
call to store.

* gcc.dg/Wstringop-overflow-62.c: Adjust expected diagnostics.
gcc/gimple-fold.c
gcc/testsuite/gcc.dg/Wstringop-overflow-62.c