Commit e812d4dd by Eric Botcazou Committed by Eric Botcazou

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
parent fcf7081c
2018-06-02 Eric Botcazou <ebotcazou@adacore.com> 2018-06-02 Eric Botcazou <ebotcazou@adacore.com>
* 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.
2018-06-02 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/ada-tree.h (TYPE_PADDING_FOR_COMPONENT): New macro. * gcc-interface/ada-tree.h (TYPE_PADDING_FOR_COMPONENT): New macro.
* gcc-interface/decl.c (gnat_to_gnu_component_type): Cache the padding * gcc-interface/decl.c (gnat_to_gnu_component_type): Cache the padding
type built for an aliased component with variable size. type built for an aliased component with variable size.
......
...@@ -601,16 +601,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) ...@@ -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 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 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 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 if (!definition
&& !No_Initialization (Declaration_Node (gnat_entity)) && !No_Initialization (Declaration_Node (gnat_entity))
&& Present (Expression (Declaration_Node (gnat_entity))) && Present (gnat_temp = Expression (Declaration_Node (gnat_entity)))
&& Nkind (Expression (Declaration_Node (gnat_entity))) && Nkind (gnat_temp) != N_Allocator
!= N_Allocator) && (!type_annotate_only || Compile_Time_Known_Value (gnat_temp)))
/* The expression may contain N_Expression_With_Actions nodes and gnu_expr = gnat_to_gnu_external (gnat_temp);
thus object declarations from other units. Discard them. */
gnu_expr
= gnat_to_gnu_external (Expression (Declaration_Node (gnat_entity)));
/* ... fall through ... */ /* ... fall through ... */
......
...@@ -4631,9 +4631,12 @@ convert (tree type, tree expr) ...@@ -4631,9 +4631,12 @@ convert (tree type, tree expr)
etype))) etype)))
return build1 (VIEW_CONVERT_EXPR, type, expr); return build1 (VIEW_CONVERT_EXPR, type, expr);
/* If we are converting between tagged types, try to upcast properly. */ /* If we are converting between tagged types, try to upcast properly.
But don't do it if we are just annotating types since tagged types
aren't fully laid out in this mode. */
else if (ecode == RECORD_TYPE && code == RECORD_TYPE else if (ecode == RECORD_TYPE && code == RECORD_TYPE
&& TYPE_ALIGN_OK (etype) && TYPE_ALIGN_OK (type)) && TYPE_ALIGN_OK (etype) && TYPE_ALIGN_OK (type)
&& !type_annotate_only)
{ {
tree child_etype = etype; tree child_etype = etype;
do { do {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment