diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-03 10:08:31 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-03 10:08:31 +0200 |
commit | 53f29d4f64e462e90aff1a949ab7f06f8e342c49 (patch) | |
tree | bb4f13cfd5b8f50ab21047b09be02e43f7f6a8e6 /gcc/ada/exp_ch4.adb | |
parent | c0b118502029cede7f7fe9fa16bae5ff936ac461 (diff) | |
download | gcc-53f29d4f64e462e90aff1a949ab7f06f8e342c49.zip gcc-53f29d4f64e462e90aff1a949ab7f06f8e342c49.tar.gz gcc-53f29d4f64e462e90aff1a949ab7f06f8e342c49.tar.bz2 |
[multiple changes]
2011-08-03 Robert Dewar <dewar@adacore.com>
* sem_ch3.adb, sem_res.adb, exp_ch13.adb, exp_disp.adb,
exp_aggr.adb: Minor reformatting.
2011-08-03 Thomas Quinot <quinot@adacore.com>
* exp_ch5.adb (Expand_N_Assignment_Statement): Do not force inlining of
tagged assignment when discriminant checks are suppressed. This is
useless and extremely costly in terms of static stack usage.
2011-08-03 Bob Duff <duff@adacore.com>
* sem_prag.adb (Get_Base_Subprogram): Do not follow Alias for instances
of generics, because this leads to the wrong entity in the wrong scope,
causing (e.g.) pragma Export_Procedure to get an error if the entity is
an instance.
(Process_Interface_Name): Follow Alias for instances of generics, to
correct for the above change.
2011-08-03 Ed Schonberg <schonberg@adacore.com>
* exp_ch4.adb (Expand_N_Selected_Component): If the discriminant value
is an integer literal it is always safe to replace the reference. In
addition, if the reference appears in the generated code for an object
declaration it is necessary to copy because otherwise the reference
might be to the uninitilized value of the discriminant of the object
itself.
2011-08-03 Pascal Obry <obry@adacore.com>
* adaint.c (__gnat_is_executable_file_attr): Fix Win32 circuitry when no
ACL used, in this case we want to check for ending .exe, not .exe
anywhere in the path.
2011-08-03 Sergey Rybin <rybin@adacore.com>
* tree_io.ads (ASIS_Version_Number): Update because of the changes in
the tree structure (semantic decoration of references to record
discriminants).
From-SVN: r177237
Diffstat (limited to 'gcc/ada/exp_ch4.adb')
-rw-r--r-- | gcc/ada/exp_ch4.adb | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 0298487..2037950 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -7594,6 +7594,18 @@ package body Exp_Ch4 is -- unless the context of an assignment can provide size information. -- Don't we have a general routine that does this??? + function Is_Subtype_Declaration return Boolean; + -- The replacement of a discriminant reference by its value is required + -- if this is part of the initialization of an temporary generated by + -- a change of representation. This shows up as the construction of a + -- discriminant constraint for a subtype declared at the same point as + -- the entity in the prefix of the selected component. + -- We recognize this case when the context of the reference is: + -- + -- subtype ST is T(Obj.D); + -- + -- The entity for Obj comes from source, and ST has the same sloc. + ----------------------- -- In_Left_Hand_Side -- ----------------------- @@ -7607,6 +7619,21 @@ package body Exp_Ch4 is and then In_Left_Hand_Side (Parent (Comp))); end In_Left_Hand_Side; + ----------------------------- + -- Is_Subtype_Declaration -- + ----------------------------- + + function Is_Subtype_Declaration return Boolean is + Par : constant Node_Id := Parent (N); + + begin + return + Nkind (Par) = N_Index_Or_Discriminant_Constraint + and then Nkind (Parent (Parent (Par))) = N_Subtype_Declaration + and then Comes_From_Source (Entity (Prefix (N))) + and then Sloc (Par) = Sloc (Entity (Prefix (N))); + end Is_Subtype_Declaration; + -- Start of processing for Expand_N_Selected_Component begin @@ -7730,9 +7757,19 @@ package body Exp_Ch4 is -- AND THEN was copied, causing problems for coverage -- analysis tools). + -- However, if the reference is part of the initialization + -- code generated for an object declaration, we must use + -- the discriminant value from the subtype constraint, + -- because the selected component may be a reference to the + -- object being initialized, whose discriminant is not yet + -- set. This only happens in complex cases involving changes + -- or representation. + if Disc = Entity (Selector_Name (N)) and then (Is_Entity_Name (Dval) - or else Is_Static_Expression (Dval)) + or else Nkind (Dval) = N_Integer_Literal + or else Is_Subtype_Declaration + or else Is_Static_Expression (Dval)) then -- Here we have the matching discriminant. Check for -- the case of a discriminant of a component that is |