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  <m...@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.

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;

Reply via email to