diff options
author | Alexandre Oliva <oliva@adacore.com> | 2021-01-25 21:45:58 -0300 |
---|---|---|
committer | Alexandre Oliva <oliva@gnu.org> | 2021-01-25 21:45:58 -0300 |
commit | 667c8e33270e267c764202021c350ef2d5d861e7 (patch) | |
tree | 9911d7823455842fe04e5055e45d1a7139e6e9f4 /gcc/testsuite/gnat.dg | |
parent | 161e4c08624e2ff9f0db8f8c6ac201af6277b6aa (diff) |
skip asan-poisoning of discarded vars
GNAT may create temporaries to hold return values of function calls.
If such a temporary is created as part of a dynamic initializer of a
variable in a unit other than the one being compiled, the initializer
is dropped, including the temporary and its binding block.
Don't issue asan mark calls for such variables, they are gone.
for gcc/ChangeLog
* gimplify.c (gimplify_decl_expr): Skip asan marking calls for
temporaries not seen in binding block, and not about to be
added as gimple variables.
for gcc/testsuite/ChangeLog
* gnat.dg/asan1.adb: New test.
* gnat.dg/asan1_pkg.ads: New additional source.
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r-- | gcc/testsuite/gnat.dg/asan1.adb | 15 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/asan1_pkg.ads | 9 |
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/asan1.adb b/gcc/testsuite/gnat.dg/asan1.adb new file mode 100644 index 00000000000..a4bc59a9a21 --- /dev/null +++ b/gcc/testsuite/gnat.dg/asan1.adb @@ -0,0 +1,15 @@ +-- { dg-do compile } +-- { dg-additional-sources asan1_pkg.ads } +-- { dg-options "-fsanitize=address" } +-- { dg-skip-if "" no_fsanitize_address } + +with Asan1_Pkg; + +procedure Asan1 is + use Asan1_Pkg; + + X, Y : E; +begin + X := C (N); + Y := V; +end Asan1; diff --git a/gcc/testsuite/gnat.dg/asan1_pkg.ads b/gcc/testsuite/gnat.dg/asan1_pkg.ads new file mode 100644 index 00000000000..fbbc1c5e7f5 --- /dev/null +++ b/gcc/testsuite/gnat.dg/asan1_pkg.ads @@ -0,0 +1,9 @@ +package Asan1_Pkg is + subtype E is Integer; + type T is array (1..32) of E; + + function N return T; + function C (P : T) return E; + + V : constant E := C (N); +end Asan1_Pkg; |