summaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2021-06-03 12:10:30 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2021-07-08 13:34:23 +0000
commit7c092960f0d116abdba7e13aaf38fbadfdefbeb0 (patch)
tree5212d98fc41671e89ba1ecb386fb4267bf0159af /gcc/ada
parent6e8b502cb6c3e30ac59fc446b2e765e5b5a9d5a6 (diff)
downloadgcc-7c092960f0d116abdba7e13aaf38fbadfdefbeb0.tar.gz
[Ada] Transient scope cleanup
gcc/ada/ * comperr.adb (Compiler_Abort): Call Sinput.Unlock, because if this is called late, then Source_Dump would crash otherwise. * debug.adb: Correct documentation of the -gnatd.9 switch. * exp_ch4.adb (Expand_Allocator_Expression): Add a comment. * exp_ch6.adb: Minor comment fixes. Add assertion. * exp_ch6.ads (Is_Build_In_Place_Result_Type): Correct comment. * exp_ch7.adb, checks.ads: Minor comment fixes.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/checks.ads2
-rw-r--r--gcc/ada/comperr.adb1
-rw-r--r--gcc/ada/debug.adb2
-rw-r--r--gcc/ada/exp_ch4.adb3
-rw-r--r--gcc/ada/exp_ch6.adb25
-rw-r--r--gcc/ada/exp_ch6.ads7
-rw-r--r--gcc/ada/exp_ch7.adb4
7 files changed, 24 insertions, 20 deletions
diff --git a/gcc/ada/checks.ads b/gcc/ada/checks.ads
index a3835d9a4fd..3b97bd0802c 100644
--- a/gcc/ada/checks.ads
+++ b/gcc/ada/checks.ads
@@ -851,7 +851,7 @@ package Checks is
-- are not following the flow graph (more properly the flow of actual
-- processing only corresponds to the flow graph for local assignments).
-- For non-local variables, we preserve the current setting, i.e. a
- -- validity check is performed when assigning to a knonwn valid global.
+ -- validity check is performed when assigning to a known valid global.
-- Note: no validity checking is required if range checks are suppressed
-- regardless of the setting of the validity checking mode.
diff --git a/gcc/ada/comperr.adb b/gcc/ada/comperr.adb
index 1687038c658..300b523213a 100644
--- a/gcc/ada/comperr.adb
+++ b/gcc/ada/comperr.adb
@@ -404,6 +404,7 @@ package body Comperr is
Set_Standard_Output;
Tree_Dump;
+ Sinput.Unlock; -- so Source_Dump can modify it
Source_Dump;
raise Unrecoverable_Error;
end if;
diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb
index 599c9c958e1..5245feb3b27 100644
--- a/gcc/ada/debug.adb
+++ b/gcc/ada/debug.adb
@@ -1101,7 +1101,7 @@ package body Debug is
-- issues (e.g., assuming that a low bound of an array parameter
-- of an unconstrained subtype belongs to the index subtype).
- -- d.9 Enable build-in-place for function calls returning some nonlimited
+ -- d.9 Disable build-in-place for function calls returning nonlimited
-- types.
------------------------------------------
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 0c5b3a24453..16f513e3226 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -1166,6 +1166,9 @@ package body Exp_Ch4 is
-- secondary stack). In that case, the object will be moved, so we do
-- want to Adjust. However, if it's a nonlimited build-in-place
-- function call, Adjust is not wanted.
+ --
+ -- Needs_Finalization (DesigT) can differ from Needs_Finalization (T)
+ -- if one of the two types is class-wide, and the other is not.
if Needs_Finalization (DesigT)
and then Needs_Finalization (T)
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index dbae7606671..1c56cb8b1d5 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -4913,7 +4913,7 @@ package body Exp_Ch6 is
-- Optimization, if the returned value (which is on the sec-stack) is
-- returned again, no need to copy/readjust/finalize, we can just pass
-- the value thru (see Expand_N_Simple_Return_Statement), and thus no
- -- attachment is needed
+ -- attachment is needed.
if Nkind (Parent (N)) = N_Simple_Return_Statement then
return;
@@ -7310,15 +7310,16 @@ package body Exp_Ch6 is
Set_Enclosing_Sec_Stack_Return (N);
- -- Optimize the case where the result is a function call. In this
- -- case the result is already on the secondary stack and no further
- -- processing is required except to set the By_Ref flag to ensure
- -- that gigi does not attempt an extra unnecessary copy. (Actually
- -- not just unnecessary but wrong in the case of a controlled type,
- -- where gigi does not know how to do a copy.)
+ -- Optimize the case where the result is a function call that also
+ -- returns on the secondary stack. In this case the result is already
+ -- on the secondary stack and no further processing is required
+ -- except to set the By_Ref flag to ensure that gigi does not attempt
+ -- an extra unnecessary copy. (Actually not just unnecessary but
+ -- wrong in the case of a controlled type, where gigi does not know
+ -- how to do a copy.)
- if Requires_Transient_Scope (Exp_Typ)
- and then Exp_Is_Function_Call
+ pragma Assert (Requires_Transient_Scope (R_Type));
+ if Exp_Is_Function_Call and then Requires_Transient_Scope (Exp_Typ)
then
Set_By_Ref (N);
@@ -7849,7 +7850,7 @@ package body Exp_Ch6 is
Compute_Returns_By_Ref (Subp);
- -- Wnen freezing a null procedure, analyze its delayed aspects now
+ -- When freezing a null procedure, analyze its delayed aspects now
-- because we may not have reached the end of the declarative list when
-- delayed aspects are normally analyzed. This ensures that dispatching
-- calls are properly rewritten when the generated _Postcondition
@@ -8219,10 +8220,6 @@ package body Exp_Ch6 is
return False;
end if;
- -- For now we test whether E denotes a function or access-to-function
- -- type whose result subtype is inherently limited. Later this test
- -- may be revised to allow composite nonlimited types.
-
if Ekind (E) in E_Function | E_Generic_Function
or else (Ekind (E) = E_Subprogram_Type
and then Etype (E) /= Standard_Void_Type)
diff --git a/gcc/ada/exp_ch6.ads b/gcc/ada/exp_ch6.ads
index 07a88c55c3c..76cec4d4e47 100644
--- a/gcc/ada/exp_ch6.ads
+++ b/gcc/ada/exp_ch6.ads
@@ -134,8 +134,11 @@ package Exp_Ch6 is
--
-- For inherently limited types in Ada 2005, True means that calls will
-- actually be build-in-place in all cases. For other types, build-in-place
- -- will be used when possible, but we need to make a copy at the call site
- -- in some cases, notably assignment statements.
+ -- will be used when possible, but we need to make a copy in some
+ -- cases. For example, for "X := F(...);" if F can see X, or if F can
+ -- propagate exceptions, we need to store its result in a temp in general,
+ -- and copy the temp into X. Also, for "return Global_Var;" Global_Var
+ -- needs to be copied into the function result object.
function Is_Build_In_Place_Function (E : Entity_Id) return Boolean;
-- Ada 2005 (AI-318-02): Returns True if E denotes a function, generic
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index b0374a39d4c..f7807acd298 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -480,7 +480,7 @@ package body Exp_Ch7 is
Skip_Self : Boolean := False) return Node_Id;
-- Subsidiary to Make_Adjust_Call and Make_Final_Call. Given the entity of
-- routine [Deep_]Adjust or [Deep_]Finalize and an object parameter, create
- -- an adjust or finalization call. Wnen flag Skip_Self is set, the related
+ -- an adjust or finalization call. When flag Skip_Self is set, the related
-- action has an effect on the components only (if any).
function Make_Deep_Proc
@@ -8126,7 +8126,7 @@ package body Exp_Ch7 is
-- end if;
-- ...
- -- When Deep_Adjust is invokes for field _parent, a value of False is
+ -- When Deep_Adjust is invoked for field _parent, a value of False is
-- provided for the flag:
-- Deep_Adjust (Obj._parent, False);