diff options
author | Ed Schonberg <schonber@gnat.com> | 2001-10-12 01:11:33 +0000 |
---|---|---|
committer | Geert Bosch <bosch@gcc.gnu.org> | 2001-10-12 03:11:33 +0200 |
commit | b14127e69159d5138b9f345d5275cfbd3a762c4f (patch) | |
tree | 02db8b5033ed15f2f8fff1feae8780c5ff581f92 /gcc | |
parent | e70ee92a44a5ab3fc7ecaacab4ccc0f826982ff2 (diff) | |
download | gcc-b14127e69159d5138b9f345d5275cfbd3a762c4f.zip gcc-b14127e69159d5138b9f345d5275cfbd3a762c4f.tar.gz gcc-b14127e69159d5138b9f345d5275cfbd3a762c4f.tar.bz2 |
exp_ch8.adb (Expand_N_Object_Renaming_Declaration): Bugfix in renaming of discriminant for mutable record type.
* exp_ch8.adb (Expand_N_Object_Renaming_Declaration): Bugfix in
renaming of discriminant for mutable record type.
From-SVN: r46222
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/exp_ch8.adb | 19 |
2 files changed, 23 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 50734bbd..be46899 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2001-10-11 Ed Schonberg <schonber@gnat.com> + + * exp_ch8.adb (Expand_N_Object_Renaming_Declaration): Bugfix in + renaming of discriminant for mutable record type. + 2001-10-11 Robert Dewar <dewar@gnat.com> * validsw.adb: Properly save -gnatVn status. diff --git a/gcc/ada/exp_ch8.adb b/gcc/ada/exp_ch8.adb index 54b1133..e59b17f 100644 --- a/gcc/ada/exp_ch8.adb +++ b/gcc/ada/exp_ch8.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- $Revision: 1.27 $ +-- $Revision$ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- @@ -67,6 +67,16 @@ package body Exp_Ch8 is -- to the object will be handled by macro substitution in the front -- end, and the back end will know to ignore the renaming declaration. + -- An additional odd case that requires processing by expansion is + -- the renaming of a discriminant of a mutable record type. The object + -- is a constant because it renames something that cannot be assigned to, + -- but in fact the underlying value can change and must be reevaluated + -- at each reference. Gigi does have a notion of a "constant view" of + -- an object, and therefore the front-end must perform the expansion. + -- For simplicity, and to bypass some obscure code-generation problem, + -- we use macro substitution for all renamed discriminants, whether the + -- enclosing type is constrained or not. + -- The other special processing required is for the case of renaming -- of an object of a class wide type, where it is necessary to build -- the appropriate subtype for the renamed object. @@ -203,6 +213,13 @@ package body Exp_Ch8 is elsif Nkind (Nam) = N_Selected_Component then if Present (Component_Clause (Entity (Selector_Name (Nam)))) then return True; + + elsif Ekind (Entity (Selector_Name (Nam))) = E_Discriminant + and then Is_Record_Type (Etype (Prefix (Nam))) + and then not Is_Concurrent_Record_Type (Etype (Prefix (Nam))) + then + return True; + else return Evaluation_Required (Prefix (Nam)); end if; |