diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2009-05-23 10:37:34 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2009-05-23 10:37:34 +0000 |
commit | aae8570a44715ff724f31c3fc2442e5f69c929a7 (patch) | |
tree | 74ed8d557ceb45bc5ec5c25ae6a3408eb6036d13 /gcc | |
parent | 92bffc1462e39ec00003876923ee8744bedcf817 (diff) | |
download | gcc-aae8570a44715ff724f31c3fc2442e5f69c929a7.zip gcc-aae8570a44715ff724f31c3fc2442e5f69c929a7.tar.gz gcc-aae8570a44715ff724f31c3fc2442e5f69c929a7.tar.bz2 |
decl.c (gnat_to_gnu_entity): Do not modify the original type because of the alignment when...
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Do not modify the
original type because of the alignment when there is an address clause.
From-SVN: r147818
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/addr6.adb | 31 |
4 files changed, 51 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d7396f1..1484a6a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2009-05-23 Eric Botcazou <ebotcazou@adacore.com> + + * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Do not modify the + original type because of the alignment when there is an address clause. + 2009-05-20 Eric Botcazou <ebotcazou@adacore.com> * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Subtype>: When diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 649b9ef..ca48c5a 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -608,17 +608,22 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) return error_mark_node; } - /* If an alignment is specified, use it if valid. Note that - exceptions are objects but don't have alignments. We must do this - before we validate the size, since the alignment can affect the - size. */ + /* If an alignment is specified, use it if valid. Note that exceptions + are objects but don't have an alignment. We must do this before we + validate the size, since the alignment can affect the size. */ if (kind != E_Exception && Known_Alignment (gnat_entity)) { gcc_assert (Present (Alignment (gnat_entity))); align = validate_alignment (Alignment (gnat_entity), gnat_entity, TYPE_ALIGN (gnu_type)); - gnu_type = maybe_pad_type (gnu_type, NULL_TREE, align, gnat_entity, - "PAD", false, definition, true); + /* No point in changing the type if there is an address clause + as the final type of the object will be a reference type. */ + if (Present (Address_Clause (gnat_entity))) + align = 0; + else + gnu_type + = maybe_pad_type (gnu_type, NULL_TREE, align, gnat_entity, + "PAD", false, definition, true); } /* If we are defining the object, see if it has a Size value and diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1de60ba..1d8379a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-05-23 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/addr6.adb: New test. + 2009-05-22 Mark Mitchell <mark@codesourcery.com> * lib/target-supports.exp (check_effective_target_arm_thumb2_ok): diff --git a/gcc/testsuite/gnat.dg/addr6.adb b/gcc/testsuite/gnat.dg/addr6.adb new file mode 100644 index 0000000..e357132 --- /dev/null +++ b/gcc/testsuite/gnat.dg/addr6.adb @@ -0,0 +1,31 @@ +-- { dg-do compile } + +procedure Addr6 is + + type Byte is mod 2**8; + + type Byte_Arr1 is array (Positive range <>) of Byte; + for Byte_Arr1'Alignment use 4; + + type Byte_Arr2 is array (Positive range <>) of Byte; + + function Length return Natural is + begin + return 1; + end; + + function Empty return Byte_Arr2 is + Null_Arr : Byte_Arr2 (1 .. 0); + begin + return Null_Arr; + end; + + A1 : Byte_Arr1 (1 .. Length); + + A2 : Byte_Arr2 (A1'Range); + for A2'Alignment use 4; + for A2'Address use A1'Address; + +begin + A2 := Empty; +end; |