sem_ch4.adb (Analyze_Conditional_Expression): handle properly overloaded expressions...
authorEd Schonberg <schonberg@adacore.com>
Tue, 7 Jul 2009 10:40:14 +0000 (10:40 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 7 Jul 2009 10:40:14 +0000 (12:40 +0200)
2009-07-07  Ed Schonberg  <schonberg@adacore.com>

* sem_ch4.adb (Analyze_Conditional_Expression): handle properly
overloaded expressions in a conditional expressions.

* sem_res.adb (Resolve): Handle properly overloaded conditional
expressions.

From-SVN: r149317

gcc/ada/ChangeLog
gcc/ada/sem_ch4.adb
gcc/ada/sem_res.adb

index 455f0a51dfefe16cab1093db735b37227dd75dbe..a923a920a60a542c362d797833e57749d267fe63 100644 (file)
@@ -1,3 +1,11 @@
+2009-07-07  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch4.adb (Analyze_Conditional_Expression): handle properly
+       overloaded expressions in a conditional expressions.
+
+       * sem_res.adb (Resolve): Handle properly overloaded conditional
+       expressions.
+
 2009-07-07  Robert Dewar  <dewar@adacore.com>
 
        * scng.adb: Minor reformattting
index 6303dd1ac418395158248e4187d69a938d167117..98cbde31d438ec2b2b384a96c138bb087b73f7b7 100644 (file)
@@ -1250,7 +1250,25 @@ package body Sem_Ch4 is
          Analyze_Expression (Else_Expr);
       end if;
 
-      Set_Etype (N, Etype (Then_Expr));
+      if not  Is_Overloaded (Then_Expr) then
+         Set_Etype (N, Etype (Then_Expr));
+      else
+         declare
+            I  : Interp_Index;
+            It : Interp;
+
+         begin
+            Set_Etype (N, Any_Type);
+            Get_First_Interp (Then_Expr, I, It);
+            while Present (It.Nam) loop
+               if Has_Compatible_Type (Else_Expr, It.Typ) then
+                  Add_One_Interp (N, It.Typ, It.Typ);
+               end if;
+
+               Get_Next_Interp (I, It);
+            end loop;
+         end;
+      end if;
    end Analyze_Conditional_Expression;
 
    -------------------------
index 95f3c9b147018de77de6675c03420dead17c8afa..ba06ee8b58cc756291cbb2fdd737f2fe0501517c 100644 (file)
@@ -2146,6 +2146,9 @@ package body Sem_Res is
                elsif Nkind (N) = N_Character_Literal then
                   Set_Etype (N, Expr_Type);
 
+               elsif Nkind (N) = N_Conditional_Expression then
+                  Set_Etype (N, Expr_Type);
+
                --  For an explicit dereference, attribute reference, range,
                --  short-circuit form (which is not an operator node), or call
                --  with a name that is an explicit dereference, there is