[Ada] Rejecting duplicate stubs

Message ID 20101005101835.GA19873@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 5, 2010, 10:18 a.m.
The compiler did not reject duplicate stubs for task bodies.

Compiling dupsep.adb  must yield:

   dupsep.adb:5:04: duplicate stub for task

package Dupsep is
   procedure Start;
end Dupsep;
package body Dupsep is
   task type Bugger is
   end Bugger;
   task body bugger is separate;
   task body bugger is separate;
   procedure Start is
   end Start;
end Dupsep;
separate (Dupsep)
task body Bugger is
end Bugger;

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

2010-10-05  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch10.adb (Analyze_Task_Body_Stub): Diagnose duplicate stub for


Index: sem_ch10.adb
--- sem_ch10.adb	(revision 164934)
+++ sem_ch10.adb	(working copy)
@@ -2272,7 +2272,16 @@  package body Sem_Ch10 is
          Set_Scope (Defining_Entity (N), Current_Scope);
          Generate_Reference (Nam, Defining_Identifier (N), 'b');
-         Set_Has_Completion (Etype (Nam));
+         --  Check for duplicate stub, if so give message and terminate
+         if Has_Completion (Etype (Nam)) then
+            Error_Msg_N ("duplicate stub for task", N);
+            return;
+         else
+            Set_Has_Completion (Etype (Nam));
+         end if;
          Analyze_Proper_Body (N, Etype (Nam));
          --  Set elaboration flag to indicate that entity is callable. This