diff options
Diffstat (limited to 'gcc/ada/sem_ch4.adb')
-rw-r--r-- | gcc/ada/sem_ch4.adb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 8f93ad3970b..12fffbda612 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -1356,11 +1356,15 @@ package body Sem_Ch4 is -- Local variables Expr : constant Node_Id := Expression (N); - FirstX : constant Node_Id := Expression (First (Alternatives (N))); Alt : Node_Id; Exp_Type : Entity_Id; Exp_Btype : Entity_Id; + FirstX : Node_Id := Empty; + -- First expression in the case for which there is some type information + -- available, i.e. it is not Any_Type, which can happen because of some + -- error, or from the use of e.g. raise Constraint_Error. + Others_Present : Boolean; -- Indicates if Others was present @@ -1379,9 +1383,17 @@ package body Sem_Ch4 is Alt := First (Alternatives (N)); while Present (Alt) loop Analyze (Expression (Alt)); + + if No (FirstX) and then Etype (Expression (Alt)) /= Any_Type then + FirstX := Expression (Alt); + end if; + Next (Alt); end loop; + -- Get our initial type from the first expression for which we got some + -- useful type information from the expression. + if not Is_Overloaded (FirstX) then Set_Etype (N, Etype (FirstX)); |