From: ebotcazou Date: Fri, 24 Apr 2009 07:01:41 +0000 (+0000) Subject: * gcc-interface/decl.c (gnat_to_gnu_entity) : If an X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=77129ada5e11ef04cbf6ecacff902ac09366f7c7;p=thirdparty%2Fgcc.git * gcc-interface/decl.c (gnat_to_gnu_entity) : If an alignment is specified, do not promote that of the component type beyond it. : Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146670 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index dd21b448436a..0c74f82f1ddf 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2009-04-24 Eric Botcazou + + * gcc-interface/decl.c (gnat_to_gnu_entity) : If an + alignment is specified, do not promote that of the component type + beyond it. + : Likewise. + 2009-04-23 Eric Botcazou * einfo.ads (Is_True_Constant): Lift restriction on atomic objects. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 746e1e8d3f8a..bc44fa06a20a 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -1957,11 +1957,28 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if (gnu_comp_size && !Is_Bit_Packed_Array (gnat_entity)) { - tree orig_tem; + tree orig_tem = tem; + unsigned int max_align; + + /* If an alignment is specified, use it as a cap on the component + type so that it can be honored for the whole type. But ignore + it for the original type of packed array types. */ + if (No (Packed_Array_Type (gnat_entity)) + && Known_Alignment (gnat_entity)) + max_align = validate_alignment (Alignment (gnat_entity), + gnat_entity, 0); + else + max_align = 0; + tem = make_type_from_size (tem, gnu_comp_size, false); - orig_tem = tem; + if (max_align > 0 && TYPE_ALIGN (tem) > max_align) + tem = orig_tem; + else + orig_tem = tem; + tem = maybe_pad_type (tem, gnu_comp_size, 0, gnat_entity, "C_PAD", false, definition, true); + /* If a padding record was made, declare it now since it will never be declared otherwise. This is necessary to ensure that its subtrees are properly marked. */ @@ -2343,13 +2360,31 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if (gnu_comp_size && !Is_Bit_Packed_Array (gnat_entity)) { - tree orig_gnu_type; + tree orig_gnu_type = gnu_type; + unsigned int max_align; + + /* If an alignment is specified, use it as a cap on the + component type so that it can be honored for the whole + type. But ignore it for the original type of packed + array types. */ + if (No (Packed_Array_Type (gnat_entity)) + && Known_Alignment (gnat_entity)) + max_align = validate_alignment (Alignment (gnat_entity), + gnat_entity, 0); + else + max_align = 0; + gnu_type = make_type_from_size (gnu_type, gnu_comp_size, false); - orig_gnu_type = gnu_type; + if (max_align > 0 && TYPE_ALIGN (gnu_type) > max_align) + gnu_type = orig_gnu_type; + else + orig_gnu_type = gnu_type; + gnu_type = maybe_pad_type (gnu_type, gnu_comp_size, 0, gnat_entity, "C_PAD", false, definition, true); + /* If a padding record was made, declare it now since it will never be declared otherwise. This is necessary to ensure that its subtrees are properly marked. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bb5ffce71f97..592aac6d985c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-04-24 Eric Botcazou + + * gnat.dg/specs/pr34799.ads: Rename to rep_clause1.ads. + * gnat.dg/specs/rep_clause2.ads: New test. + 2009-04-24 Jakub Jelinek PR rtl-optimization/39794 diff --git a/gcc/testsuite/gnat.dg/specs/pr34799.ads b/gcc/testsuite/gnat.dg/specs/rep_clause1.ads similarity index 89% rename from gcc/testsuite/gnat.dg/specs/pr34799.ads rename to gcc/testsuite/gnat.dg/specs/rep_clause1.ads index 7d06049d07f3..57f63ad3b684 100644 --- a/gcc/testsuite/gnat.dg/specs/pr34799.ads +++ b/gcc/testsuite/gnat.dg/specs/rep_clause1.ads @@ -1,7 +1,7 @@ -- { dg-do compile } -- { dg-options "-gnatwa" } -package PR34799 is +package Rep_Clause1 is generic type Custom_T is private; package Handler is @@ -16,4 +16,4 @@ package PR34799 is B at 1 range 0..0; end record; end Handler; -end PR34799; +end Rep_Clause1; diff --git a/gcc/testsuite/gnat.dg/specs/rep_clause2.ads b/gcc/testsuite/gnat.dg/specs/rep_clause2.ads new file mode 100644 index 000000000000..361c141ec40b --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/rep_clause2.ads @@ -0,0 +1,11 @@ +-- { dg-do compile } +-- { dg-options "-gnatws" } + +package Rep_Clause2 is + + type S is new String; + for S'Component_Size use 256; + + type T is new S(1..8); + +end Rep_Clause2;