diff mbox

[Ada] Allow 'Mod attribute in Ada 95 mode

Message ID 20100622121541.GA32760@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet June 22, 2010, 12:15 p.m. UTC
This patch allows 'Mod to be recognized and properly processed in Ada
95 mode as an implementation defined attribute. The following program
now compiles quietly in either Ada 95 or Ada 2005 mode:

package mod95a is
   type r is mod 2 ** 16;
   b : constant := r'mod (1);
end;

The following program compiles quietly in Ada 2005 mode, but in Ada 95
mode gets a message complaining that 'Mod violates the restriction:

pragma Restrictions (No_Implementation_Attributes);
package mod95b is
   type r is mod 2 ** 16;
   b : constant := r'mod (1);
end;

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

2010-06-22  Robert Dewar  <dewar@adacore.com>

	* par-ch4.adb (P_Name): Recognize 'Mod attribute in Ada 95 mode
	* sem_attr.adb (Attribute_05): Add Name_Mod so that 'Mod recognized in
	Ada 95 mode as an implementation defined attribute.
diff mbox

Patch

Index: par-ch4.adb
===================================================================
--- par-ch4.adb	(revision 161073)
+++ par-ch4.adb	(working copy)
@@ -437,7 +437,7 @@  package body Ch4 is
                elsif Token = Tok_Access then
                   Attr_Name := Name_Access;
 
-               elsif Token = Tok_Mod and then Ada_Version = Ada_05 then
+               elsif Token = Tok_Mod and then Ada_Version >= Ada_95 then
                   Attr_Name := Name_Mod;
 
                elsif Apostrophe_Should_Be_Semicolon then
Index: sem_attr.adb
===================================================================
--- sem_attr.adb	(revision 161136)
+++ sem_attr.adb	(working copy)
@@ -136,6 +136,7 @@  package body Sem_Attr is
 
    Attribute_05 : constant Attribute_Class_Array := Attribute_Class_Array'(
       Attribute_Machine_Rounding  |
+      Attribute_Mod               |
       Attribute_Priority          |
       Attribute_Stream_Size       |
       Attribute_Wide_Wide_Width   => True,