aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasiliy Fofanov <fofanov@adacore.com>2020-05-22 13:22:41 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-07-08 10:55:55 -0400
commitb19c922bf471e4202bf4853cab9575d4a924657c (patch)
tree0b2c729b6b94a0345e14979abd23aace1e94cba3
parent72145c1ee83fc5d7b8f65084442a7397bf154154 (diff)
downloadgcc-b19c922bf471e4202bf4853cab9575d4a924657c.zip
gcc-b19c922bf471e4202bf4853cab9575d4a924657c.tar.gz
gcc-b19c922bf471e4202bf4853cab9575d4a924657c.tar.bz2
[Ada] Optional warning on build-in-place function calls
gcc/ada/ * debug.adb: Document new switch. * exp_ch6.adb (Warn_BIP): New function that warns if the switch is on. Call it from Make_Build_In_Place_* functions. Warn_BIP is not needed in Make_Build_In_Place_Iface_*, because those call Make_Build_In_Place_Call_In_Object_Declaration or similar.
-rw-r--r--gcc/ada/debug.adb6
-rw-r--r--gcc/ada/exp_ch6.adb23
2 files changed, 28 insertions, 1 deletions
diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb
index 0f73c2a..316a798 100644
--- a/gcc/ada/debug.adb
+++ b/gcc/ada/debug.adb
@@ -173,7 +173,7 @@ package body Debug is
-- d_z Enable Put_Image on tagged types
-- d_A Stop generation of ALI file
- -- d_B
+ -- d_B Warn on build-in-place function calls
-- d_C
-- d_D
-- d_E
@@ -1003,6 +1003,10 @@ package body Debug is
-- d_A Do not generate ALI files by setting Opt.Disable_ALI_File.
+ -- d_B Warn on build-in-place function calls. This allows users to
+ -- inspect their code in case it triggers compiler bugs related
+ -- to build-in-place calls. See known-problem entries for details.
+
-- d_F The compiler encodes the full path from an invocation construct to
-- an external target, offering additional information to GNATBIND for
-- purposes of error diagnostics.
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index c882630..e3fcbc7 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -306,6 +306,10 @@ package body Exp_Ch6 is
-- out of. This ensures that the secondary stack is not released; otherwise
-- the function result would be reclaimed before returning to the caller.
+ procedure Warn_BIP (Func_Call : Node_Id);
+ -- Give a warning on a build-in-place function call if the -gnatd_B switch
+ -- was given.
+
----------------------------------------------
-- Add_Access_Actual_To_Build_In_Place_Call --
----------------------------------------------
@@ -8739,6 +8743,8 @@ package body Exp_Ch6 is
raise Program_Error;
end if;
+ Warn_BIP (Func_Call);
+
Result_Subt := Available_View (Etype (Function_Id));
-- Create a temp for the function result. In the caller-allocates case,
@@ -8995,6 +9001,8 @@ package body Exp_Ch6 is
raise Program_Error;
end if;
+ Warn_BIP (Func_Call);
+
Result_Subt := Etype (Function_Id);
-- If the build-in-place function returns a controlled object, then the
@@ -9142,6 +9150,8 @@ package body Exp_Ch6 is
raise Program_Error;
end if;
+ Warn_BIP (Func_Call);
+
Result_Subt := Etype (Func_Id);
-- When the result subtype is unconstrained, an additional actual must
@@ -9286,6 +9296,8 @@ package body Exp_Ch6 is
Set_Is_Expanded_Build_In_Place_Call (Func_Call);
+ Warn_BIP (Func_Call);
+
-- Create an access type designating the function's result subtype.
-- We use the type of the original call because it may be a call to an
-- inherited operation, which the expansion has replaced with the parent
@@ -10330,4 +10342,15 @@ package body Exp_Ch6 is
return Unqual_BIP_Function_Call (Expr);
end Unqual_BIP_Iface_Function_Call;
+ --------------
+ -- Warn_BIP --
+ --------------
+
+ procedure Warn_BIP (Func_Call : Node_Id) is
+ begin
+ if Debug_Flag_Underscore_BB then
+ Error_Msg_N ("build-in-place function call?", Func_Call);
+ end if;
+ end Warn_BIP;
+
end Exp_Ch6;