aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2021-01-25 21:45:58 -0300
committerAlexandre Oliva <oliva@gnu.org>2021-01-25 21:45:58 -0300
commit667c8e33270e267c764202021c350ef2d5d861e7 (patch)
tree9911d7823455842fe04e5055e45d1a7139e6e9f4 /gcc/gimplify.c
parent161e4c08624e2ff9f0db8f8c6ac201af6277b6aa (diff)
downloadgcc-667c8e33270e267c764202021c350ef2d5d861e7.zip
gcc-667c8e33270e267c764202021c350ef2d5d861e7.tar.gz
gcc-667c8e33270e267c764202021c350ef2d5d861e7.tar.bz2
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/gimplify.c')
-rw-r--r--gcc/gimplify.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index d2ac5f9..95d55bb 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1795,7 +1795,13 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
&& !DECL_HAS_VALUE_EXPR_P (decl)
&& DECL_ALIGN (decl) <= MAX_SUPPORTED_STACK_ALIGNMENT
&& dbg_cnt (asan_use_after_scope)
- && !gimplify_omp_ctxp)
+ && !gimplify_omp_ctxp
+ /* GNAT introduces temporaries to hold return values of calls in
+ initializers of variables defined in other units, so the
+ declaration of the variable is discarded completely. We do not
+ want to issue poison calls for such dropped variables. */
+ && (DECL_SEEN_IN_BIND_EXPR_P (decl)
+ || (DECL_ARTIFICIAL (decl) && DECL_NAME (decl) == NULL_TREE)))
{
asan_poisoned_variables->add (decl);
asan_poison_variable (decl, false, seq_p);