]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Wrong detection of potentially blocking call in protected object
authorJavier Miranda <miranda@adacore.com>
Thu, 6 Aug 2020 17:56:50 +0000 (13:56 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 21 Oct 2020 07:22:47 +0000 (03:22 -0400)
gcc/ada/

* exp_ch9.adb (Build_Task_Activation_Call): Do not generate a
call to activate tasks if we are within the scope of a protected
type and pragma Detect_Blocking is active.

gcc/ada/exp_ch9.adb

index 26e7321ef88b6093f1c1ec81ca960bfbc320dc9f..f56b746357535b91cfaf1f30e43a45916c017cbf 100644 (file)
@@ -4960,6 +4960,18 @@ package body Exp_Ch9 is
 
       if No (Chain) or else Is_Ignored_Ghost_Entity (Chain) then
          return;
+
+      --  The availability of the activation chain entity does not ensure
+      --  that we have tasks to activate because it may have been declared
+      --  by the frontend to pass a required extra formal to a build-in-place
+      --  subprogram call. If we are within the scope of a protected type and
+      --  pragma Detect_Blocking is active we can assume that no tasks will be
+      --  activated; if tasks are created in a protected object and this pragma
+      --  is active then the frontend emits a warning and Program_Error is
+      --  raised at runtime.
+
+      elsif Detect_Blocking and then Within_Protected_Type (Current_Scope) then
+         return;
       end if;
 
       --  The location of the activation call must be as close as possible to