diff mbox

[Ada] Illegal calls in entry call alternatives

Message ID 20121106100534.GA11808@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Nov. 6, 2012, 10:05 a.m. UTC
Entry call alternaitives in timed or conditional entry calls, as well as in
asynchronous transfers of control, must be entry calls (looking through
renamings) or dispatching calls to interface primitives. This patch rejects
an illegal case that was not previously diagnosed, namely an indirect call
to a parameterless procedure.

Compilling aa-syncrhonized_calls.adb must be rejected with the message:

   aa-synchronized_calls.adb:9:13:
          entry call or dispatching primitive of interface required

package AA is
end;
--
package AA.Synchronized_Calls is

   type Procedure_Ptr_T is access procedure;

   protected Protected_Calls is
      procedure Call
         (Process : Procedure_Ptr_T;
          Timeout : Duration);
   end;
end;
--
package body AA.Synchronized_Calls is

   protected body Protected_Calls is
      procedure Call
         (Process : Procedure_Ptr_T;
          Timeout : Duration) is
      begin
         select
            Process.all;
         or
            delay Timeout;
         end select;
      end;
   end;
end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-11-06  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch9.adb (Analyze_Entry_Call_Alternative,
	Check_Triggering_Statement): Reject properly an indirect call.
diff mbox

Patch

Index: sem_ch9.adb
===================================================================
--- sem_ch9.adb	(revision 193215)
+++ sem_ch9.adb	(working copy)
@@ -1470,6 +1470,15 @@ 
 
       Analyze (Call);
 
+      --  An indirect call in this context  is illegal. A procedure call that
+      --  does not involve a renaming of an entry is illegal as well, but this
+      --  and other semantic errors are caught during resolution.
+
+      if Nkind (Call) = N_Explicit_Dereference then
+         Error_Msg_N
+           ("entry call or dispatching primitive of interface required ", N);
+      end if;
+
       if Is_Non_Empty_List (Statements (N)) then
          Analyze_Statements (Statements (N));
       end if;
@@ -3304,6 +3313,11 @@ 
                  ("dispatching operation of limited or synchronized " &
                   "interface required (RM 9.7.2(3))!", Error_Node);
             end if;
+
+         elsif Nkind (Trigger) = N_Explicit_Dereference then
+            Error_Msg_N
+              ("entry call or dispatching primitive of interface required ",
+                Trigger);
          end if;
       end if;
    end Check_Triggering_Statement;