Patchwork [Ada] Disallow Interrupt_Handler and Attach_Handler in generics

login
register
mail settings
Submitter Arnaud Charlet
Date Oct. 8, 2010, 12:57 p.m.
Message ID <20101008125724.GA13121@adacore.com>
Download mbox | patch
Permalink /patch/67192/
State New
Headers show

Comments

Arnaud Charlet - Oct. 8, 2010, 12:57 p.m.
In accordance with AI 0033, this patch prohibits the use of either
of the pragmas Interrupt_Handler or Attach_Handler within a generic,
as shown by the following example compiled with -gnatj60:

Compiling: genericih.adb

     1. package body GenericIH is
     2.    protected type Handler is
     3.       procedure My_Handler;
     4.       pragma Interrupt_Handler (My_Handler);
              |
        >>> pragma "Interrupt_Handler" cannot be used
            inside a generic

     5.    end Handler;
     6.
     7.    protected body Handler is
     8.       procedure My_Handler is begin null; end;
     9.    end Handler;
    10. end GenericIH;

Compiling: genericih.ads

     1. generic
     2. package GenericIH is
     3.    pragma Elaborate_Body;
     4. end;

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

2010-10-08  Robert Dewar  <dewar@adacore.com>

	* sem_prag.adb (Check_Interrupt_Or_Attach_Handler): Pragmas
	Interrupt_Handler and Attach_Handler not allowed in generics.

Patch

Index: sem_prag.adb
===================================================================
--- sem_prag.adb	(revision 165170)
+++ sem_prag.adb	(working copy)
@@ -1305,6 +1305,10 @@  package body Sem_Prag is
             Error_Pragma_Arg
               ("argument for pragma% must be library level entity", Arg1);
          end if;
+
+         if Inside_A_Generic then
+            Error_Pragma ("pragma% cannot be used inside a generic");
+         end if;
       end Check_Interrupt_Or_Attach_Handler;
 
       -------------------------------------------