===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 1992-2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -690,41 +690,6 @@
Obj_Ref : Node_Id;
Curr : Entity_Id;
- function May_Be_External_Call return Boolean;
- -- If the 'Access is to a local operation, but appears in a context
- -- where it may lead to a call from outside the object, we must treat
- -- this as an external call. Clearly we cannot tell without full
- -- flow analysis, and a subsequent call that uses this 'Access may
- -- lead to a bounded error (trying to seize locks twice, e.g.). For
- -- now we treat 'Access as a potential external call if it is an actual
- -- in a call to an outside subprogram.
-
- --------------------------
- -- May_Be_External_Call --
- --------------------------
-
- function May_Be_External_Call return Boolean is
- Subp : Entity_Id;
- Par : Node_Id := Parent (N);
-
- begin
- -- Account for the case where the Access attribute is part of a
- -- named parameter association.
-
- if Nkind (Par) = N_Parameter_Association then
- Par := Parent (Par);
- end if;
-
- if Nkind (Par) in N_Subprogram_Call
- and then Is_Entity_Name (Name (Par))
- then
- Subp := Entity (Name (Par));
- return not In_Open_Scopes (Scope (Subp));
- else
- return False;
- end if;
- end May_Be_External_Call;
-
-- Start of processing for Expand_Access_To_Protected_Op
begin
@@ -733,15 +698,15 @@
-- protected body of the current enclosing operation.
if Is_Entity_Name (Pref) then
- if May_Be_External_Call then
- Sub :=
- New_Occurrence_Of (External_Subprogram (Entity (Pref)), Loc);
- else
- Sub :=
- New_Occurrence_Of
- (Protected_Body_Subprogram (Entity (Pref)), Loc);
- end if;
+ -- All indirect calls are external calls, so must do locking and
+ -- barrier reevaluation, even if the 'Access occurs within the
+ -- protected body. Hence the call to External_Subprogram, as opposed
+ -- to Protected_Body_Subprogram, below. See RM-9.5(5). This means
+ -- that indirect calls from within the same protected body will
+ -- deadlock, as allowed by RM-9.5.1(8,15,17).
+ Sub := New_Occurrence_Of (External_Subprogram (Entity (Pref)), Loc);
+
-- Don't traverse the scopes when the attribute occurs within an init
-- proc, because we directly use the _init formal of the init proc in
-- that case.