diff options
author | Ed Schonberg <schonber@gnat.com> | 2001-12-05 00:56:39 +0000 |
---|---|---|
committer | Geert Bosch <bosch@gcc.gnu.org> | 2001-12-05 01:56:39 +0100 |
commit | c6d289f47ef7f721d019b63c820494bc564e1bab (patch) | |
tree | c23ca8a0ad4c53a3a5b5a4062b838af1113b06e1 /gcc | |
parent | 5917e80db6c2cad4ff2eec14f7a9ced3012d25b9 (diff) | |
download | gcc-c6d289f47ef7f721d019b63c820494bc564e1bab.zip gcc-c6d289f47ef7f721d019b63c820494bc564e1bab.tar.gz gcc-c6d289f47ef7f721d019b63c820494bc564e1bab.tar.bz2 |
exp_util.adb (Must_Be_Aligned): Return false for a component of a record that has other packed components.
* exp_util.adb (Must_Be_Aligned): Return false for a component of a
record that has other packed components.
From-SVN: r47638
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/exp_util.adb | 29 |
2 files changed, 33 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 533df40..0f72ac5 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2001-12-04 Ed Schonberg <schonber@gnat.com> + + * exp_util.adb (Must_Be_Aligned): Return false for a component of a + record that has other packed components. + 2001-12-04 Douglass B. Rupp <rupp@gnat.com> * adaint.c: Minor cleanups. diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 52c1998..4cdd988 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- $Revision: 1.2 $ +-- $Revision$ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- @@ -2497,6 +2497,30 @@ package body Exp_Util is function Must_Be_Aligned (Obj : Node_Id) return Boolean is Typ : constant Entity_Id := Etype (Obj); + function In_Partially_Packed_Record (Comp : Entity_Id) return Boolean; + -- If the component is in a record that contains previous packed + -- components, consider it unaligned because the back-end might + -- choose to pack the rest of the record. Lead to less efficient code, + -- but safer vis-a-vis of back-end choices. + + function In_Partially_Packed_Record (Comp : Entity_Id) return Boolean is + Rec_Type : constant Entity_Id := Scope (Comp); + Prev_Comp : Entity_Id; + begin + Prev_Comp := First_Entity (Rec_Type); + while Present (Prev_Comp) loop + if Is_Packed (Etype (Prev_Comp)) then + return True; + + elsif Prev_Comp = Comp then + return False; + end if; + + Next_Entity (Prev_Comp); + end loop; + + return False; + end In_Partially_Packed_Record; begin -- If object is strictly aligned, we can quit now @@ -2537,6 +2561,9 @@ package body Exp_Util is elsif Present (Component_Clause (Entity (Selector_Name (Obj)))) then return False; + elsif In_Partially_Packed_Record (Entity (Selector_Name (Obj))) then + return False; + -- In all other cases, go look at prefix else |