diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-02-29 09:02:46 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-02-29 09:02:46 +0000 |
commit | 95164e7198c69e87adf63516993537c834b4512e (patch) | |
tree | 393bcdf9df2f8ceab15cb45aae341cbc2d86146c /gcc/ada/gcc-interface/utils.c | |
parent | a890896f9d530c1501c3e053174a8f4bcb1478e8 (diff) |
* gcc-interface/ada-tree.h (DECL_RETURN_VALUE_P): New macro.
* gcc-interface/gigi.h (gigi): Remove useless attribute.
(gnat_gimplify_expr): Likewise.
(gnat_to_gnu_external): Declare.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: Factor out
code dealing with the expression of external constants into...
Invoke gnat_to_gnu_external instead.
<E_Variable>: Invoke gnat_to_gnu_external to translate renamed objects
when not for a definition. Deal with COMPOUND_EXPR and variables with
DECL_RETURN_VALUE_P set for renamings and with the case of a dangling
'reference to a function call in a renaming. Remove obsolete test and
adjust associated comment.
* gcc-interface/trans.c (Call_to_gnu): Set DECL_RETURN_VALUE_P on the
temporaries created to hold the return value, if any.
(gnat_to_gnu_external): ...this. New function.
* gcc-interface/utils.c (create_var_decl): Detect a constant created
to hold 'reference to function call.
* gcc-interface/utils2.c (build_unary_op) <ADDR_EXPR>: Add folding
for COMPOUND_EXPR in the DECL_RETURN_VALUE_P case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233804 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index ff21e7b5ff05..6d4770df998b 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -2464,6 +2464,22 @@ create_var_decl (tree name, tree asm_name, tree type, tree init, && !AGGREGATE_TYPE_P (type)) ? CONST_DECL : VAR_DECL, name, type); + /* Detect constants created by the front-end to hold 'reference to function + calls for stabilization purposes. This is needed for renaming. */ + if (const_flag && init && POINTER_TYPE_P (type)) + { + tree inner = init; + if (TREE_CODE (inner) == COMPOUND_EXPR) + inner = TREE_OPERAND (inner, 1); + inner = remove_conversions (inner, true); + if (TREE_CODE (inner) == ADDR_EXPR + && ((TREE_CODE (TREE_OPERAND (inner, 0)) == CALL_EXPR + && !call_is_atomic_load (TREE_OPERAND (inner, 0))) + || (TREE_CODE (TREE_OPERAND (inner, 0)) == VAR_DECL + && DECL_RETURN_VALUE_P (TREE_OPERAND (inner, 0))))) + DECL_RETURN_VALUE_P (var_decl) = 1; + } + /* If this is external, throw away any initializations (they will be done elsewhere) unless this is a constant for which we would like to remain able to get the initializer. If we are defining a global here, leave a |