public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Only allow boolean conditional expression in ALFA
@ 2011-08-03 15:28 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2011-08-03 15:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Yannick Moy

[-- Attachment #1: Type: text/plain, Size: 480 bytes --]

Previous patch allowed any type of conditional expression in ALFA. Now restrict
this to boolean expressions only. Possibly subject to change later on when
translation from ALFA improves.

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

2011-08-03  Yannick Moy  <moy@adacore.com>

	* sem_ch4.adb (Analyze_Conditional_Expression): only allow boolean
	conditional expression in ALFA.
	* sem_res.adb (Resolve_Conditional_Expression): mark non-boolean
	expressions as not in ALFA.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1437 bytes --]

Index: sem_res.adb
===================================================================
--- sem_res.adb	(revision 177275)
+++ sem_res.adb	(working copy)
@@ -5860,6 +5860,10 @@
          Append_To (Expressions (N), Error);
       end if;
 
+      if Root_Type (Typ) /= Standard_Boolean then
+         Mark_Non_ALFA_Subprogram;
+      end if;
+
       Set_Etype (N, Typ);
       Eval_Conditional_Expression (N);
    end Resolve_Conditional_Expression;
Index: sem_ch4.adb
===================================================================
--- sem_ch4.adb	(revision 177285)
+++ sem_ch4.adb	(working copy)
@@ -1524,15 +1524,21 @@
 
       Else_Expr := Next (Then_Expr);
 
-      --  In ALFA, conditional expressions are allowed:
+      --  In ALFA, boolean conditional expressions are allowed:
       --    * if they have no ELSE part, in which case the expression is
       --      equivalent to
+
       --        NOT Condition OR ELSE Then_Expr
+
       --    * in pre- and postconditions, where the Condition cannot have side-
       --      effects (in ALFA) and thus the expression is equivalent to
+
       --        (Condition AND THEN Then_Expr)
       --          and (NOT Condition AND THEN Then_Expr)
 
+      --  Non-boolean conditional expressions are marked as not in ALFA during
+      --  resolution.
+
       if Present (Else_Expr) and then not In_Pre_Post_Expression then
          Mark_Non_ALFA_Subprogram;
       end if;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-08-03 15:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-03 15:28 [Ada] Only allow boolean conditional expression in ALFA Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).