This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Conformance for quantified expressions


Ada2012 Quantified expressions can appear in default expressions, and must be
checked for conformance.
The following compilation:

     gcc -c -gnat12 -gnata conf.adb

must yield:

   conf.adb:16:14: not fully conformant with declaration at line 4
   conf.adb:16:14: default expression for "X" does not match
   conf.adb:22:14: not fully conformant with declaration at line 6
   conf.adb:22:14: default expression for "X" does not match
   conf.adb:29:14: not fully conformant with declaration at line 9
   conf.adb:29:14: default expression for "X" does not match
   conf.adb:37:14: not fully conformant with declaration at line 12
   conf.adb:37:14: default expression for "X" does not match

---
procedure Conf is
   table : array (1..10) of integer := (others => 1);

   procedure Maybe (X : Boolean := (for all E of table => E = 1));

   procedure Peut_Etre
    (X : Boolean := (for all I in table'range => Table (I) = 1));

   procedure Quizas
    (X : Boolean := (for all I in table'range => Table (I) = 1));

   procedure Qui_Sait
    (X : Boolean := (for all I of table => Table (I) = 1));

  -- Expression doesn't match
   procedure Maybe (X : Boolean := (for all E of table => E = 2)) is
   begin
      null;
   end;

   --  loop parameter doesn't match
   procedure Peut_Etre
     (X : Boolean := (for all J in table'range => Table (J) = 1)) is
   begin
      null;
   end;

  --  discrete range doesn't match
   procedure Quizas
     (X : Boolean := 
       (for all I in table'first  .. table'last => Table (I) = 1)) is
   begin
      null;
   end;

   --  discrete range doesn't match
   procedure Qui_Sait
       (X : Boolean := (for all I in reverse table'range => Table (I) = 1)) is
   begin
      null;
   end;

begin
   Table (5) := 0;
   Maybe;
   Qui_Sait;
   Quizas;
end;

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

2011-08-01  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch6.adb (Fully_Conformant_Expressions): handle quantified
	expressions.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]