From e63d76234d18cac731c4f3610d513bd8b39b5520 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 21 Jul 2021 09:14:24 +0200 Subject: c/101512 - fix missing address-taking in c_common_mark_addressable_vec c_common_mark_addressable_vec fails to look through C_MAYBE_CONST_EXPR in the case it isn't at the toplevel. 2021-07-21 Richard Biener PR c/101512 gcc/c-family/ * c-common.c (c_common_mark_addressable_vec): Look through C_MAYBE_CONST_EXPR even if not at the toplevel. gcc/testsuite/ * gcc.dg/torture/pr101512.c: New testcase. --- gcc/c-family/c-common.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gcc/c-family/c-common.c') diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index aacdfb4..21da679 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -6894,10 +6894,13 @@ complete_flexible_array_elts (tree init) void c_common_mark_addressable_vec (tree t) { - if (TREE_CODE (t) == C_MAYBE_CONST_EXPR) - t = C_MAYBE_CONST_EXPR_EXPR (t); - while (handled_component_p (t)) - t = TREE_OPERAND (t, 0); + while (handled_component_p (t) || TREE_CODE (t) == C_MAYBE_CONST_EXPR) + { + if (TREE_CODE (t) == C_MAYBE_CONST_EXPR) + t = C_MAYBE_CONST_EXPR_EXPR (t); + else + t = TREE_OPERAND (t, 0); + } if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL && TREE_CODE (t) != COMPOUND_LITERAL_EXPR) -- cgit v1.1