From 2baccce2f7497923aa1a9bcf2e6c90e0a3e74992 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Mon, 21 Sep 1992 06:46:22 +0000 Subject: [PATCH] (put_var_into_stack): Check REG != 0 before dereference. From-SVN: r2198 --- gcc/function.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gcc/function.c b/gcc/function.c index 9295cb1121c..a7e143805d8 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -818,11 +818,18 @@ put_var_into_stack (decl) /* Get the current rtl used for this object and it's original mode. */ reg = TREE_CODE (decl) == SAVE_EXPR ? SAVE_EXPR_RTL (decl) : DECL_RTL (decl); - promoted_mode = GET_MODE (reg); + + /* No need to do anything if decl has no rtx yet + since in that case caller is setting TREE_ADDRESSABLE + and a stack slot will be assigned when the rtl is made. */ + if (reg == 0) + return; /* Get the declared mode for this object. */ decl_mode = (TREE_CODE (decl) == SAVE_EXPR ? TYPE_MODE (TREE_TYPE (decl)) : DECL_MODE (decl)); + /* Get the mode it's actually stored in. */ + promoted_mode = GET_MODE (reg); /* If this variable comes from an outer function, find that function's saved context. */ @@ -831,12 +838,6 @@ put_var_into_stack (decl) if (function->decl == context) break; - /* No need to do anything if decl has no rtx yet - since in that case caller is setting TREE_ADDRESSABLE - and a stack slot will be assigned when the rtl is made. */ - if (reg == 0) - return; - /* If this is a variable-size object with a pseudo to address it, put that pseudo into the stack, if the var is nonlocal. */ if (DECL_NONLOCAL (decl) -- 2.30.2