aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2018-06-02 11:11:40 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2018-06-02 11:11:40 +0000
commite812d4dd5df9befff0bc077349453e6126a8807d (patch)
tree5c09157db8861d050ecc205a2deefa265593408f /gcc/ada/gcc-interface/decl.c
parentfcf7081cf9b5f2ccbc5167806fb8e377f100efec (diff)
downloadgcc-e812d4dd5df9befff0bc077349453e6126a8807d.zip
gcc-e812d4dd5df9befff0bc077349453e6126a8807d.tar.gz
gcc-e812d4dd5df9befff0bc077349453e6126a8807d.tar.bz2
decl.c (gnat_to_gnu_entity): If this is not a definition...
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: If this is not a definition, retrieve the expression only if it's a compile-time known value if we are just annotating types. * gcc-interface/utils.c (convert): Do not try to upcast properly for a conversion between tagged types in type_annotate_only mode. From-SVN: r261113
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r--gcc/ada/gcc-interface/decl.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 8f3595e..c482884 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -601,16 +601,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
was defined to represent. This is necessary to avoid generating dumb
elaboration code in simple cases, but we may throw it away later if it
is not a constant. But do not retrieve it if it is an allocator since
- the designated type might still be dummy at this point. */
+ the designated type might still be dummy at this point. Note that we
+ invoke gnat_to_gnu_external and not gnat_to_gnu because the expression
+ may contain N_Expression_With_Actions nodes and thus declarations of
+ objects from other units that we need to discard. */
if (!definition
&& !No_Initialization (Declaration_Node (gnat_entity))
- && Present (Expression (Declaration_Node (gnat_entity)))
- && Nkind (Expression (Declaration_Node (gnat_entity)))
- != N_Allocator)
- /* The expression may contain N_Expression_With_Actions nodes and
- thus object declarations from other units. Discard them. */
- gnu_expr
- = gnat_to_gnu_external (Expression (Declaration_Node (gnat_entity)));
+ && Present (gnat_temp = Expression (Declaration_Node (gnat_entity)))
+ && Nkind (gnat_temp) != N_Allocator
+ && (!type_annotate_only || Compile_Time_Known_Value (gnat_temp)))
+ gnu_expr = gnat_to_gnu_external (gnat_temp);
/* ... fall through ... */