aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2008-11-15 12:34:00 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2008-11-15 12:34:00 +0000
commita5b8aacdd2b91ccfa37825d358141bad4cba1d11 (patch)
tree567b03033f3048fcf0d71e7e6fd0ffbbaac668fe /gcc/ada/gcc-interface/decl.c
parent4364e8514629e69a37e260ebb468734ec95bfaa9 (diff)
downloadgcc-a5b8aacdd2b91ccfa37825d358141bad4cba1d11.zip
gcc-a5b8aacdd2b91ccfa37825d358141bad4cba1d11.tar.gz
gcc-a5b8aacdd2b91ccfa37825d358141bad4cba1d11.tar.bz2
decl.c (gnat_to_gnu_entity): Force constants initialized to a static constant to be statically allocated...
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Force constants initialized to a static constant to be statically allocated even if they are of a padding type, provided the original type also has constant size. From-SVN: r141883
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r--gcc/ada/gcc-interface/decl.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 22ca3a5..3266e6d 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -1281,12 +1281,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* If this is constant initialized to a static constant and the
object has an aggregate type, force it to be statically
- allocated. */
- if (const_flag && gnu_expr && TREE_CONSTANT (gnu_expr)
+ allocated. This will avoid an initialization copy. */
+ if (!static_p && const_flag
+ && gnu_expr && TREE_CONSTANT (gnu_expr)
+ && AGGREGATE_TYPE_P (gnu_type)
&& host_integerp (TYPE_SIZE_UNIT (gnu_type), 1)
- && (AGGREGATE_TYPE_P (gnu_type)
- && !(TREE_CODE (gnu_type) == RECORD_TYPE
- && TYPE_IS_PADDING_P (gnu_type))))
+ && !(TREE_CODE (gnu_type) == RECORD_TYPE
+ && TYPE_IS_PADDING_P (gnu_type)
+ && !host_integerp (TYPE_SIZE_UNIT
+ (TREE_TYPE (TYPE_FIELDS (gnu_type))), 1)))
static_p = true;
gnu_decl = create_var_decl (gnu_entity_id, gnu_ext_name, gnu_type,