From bc795e3e039342e74d2d2b0515dd190f7d24ec65 Mon Sep 17 00:00:00 2001 From: Yannick Moy Date: Wed, 20 Apr 2016 10:44:17 +0000 Subject: [PATCH] sem_ch4.adb: Fix typos in comments. 2016-04-20 Yannick Moy * sem_ch4.adb: Fix typos in comments. * sem_res.adb (Resolve_Case_Expression): Fix type of case alternatives. From-SVN: r235263 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/sem_ch4.adb | 4 ++-- gcc/ada/sem_res.adb | 27 +++++++++++++++++++++------ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 185040a55cc..1409c795e35 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2016-04-20 Yannick Moy + + * sem_ch4.adb: Fix typos in comments. + * sem_res.adb (Resolve_Case_Expression): Fix type of case alternatives. + 2016-04-20 Ed Schonberg * sem_ch4.adb (Analyze_Selected_Component): A reference to the diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 6226c8c137a..6ba51e8f3d8 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -2175,12 +2175,12 @@ package body Sem_Ch4 is begin Set_Etype (N, Any_Type); - -- Loop through intepretations of Then_Expr + -- Loop through interpretations of Then_Expr Get_First_Interp (Then_Expr, I, It); while Present (It.Nam) loop - -- Add possible intepretation of Then_Expr if no Else_Expr, or + -- Add possible interpretation of Then_Expr if no Else_Expr, or -- Else_Expr is present and has a compatible type. if No (Else_Expr) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 23ce8279b3f..2ce47e23f97 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -6509,13 +6509,27 @@ package body Sem_Res is ----------------------------- procedure Resolve_Case_Expression (N : Node_Id; Typ : Entity_Id) is - Alt : Node_Id; - Is_Dyn : Boolean; + Alt : Node_Id; + Alt_Expr : Node_Id; + Alt_Typ : Entity_Id; + Is_Dyn : Boolean; begin Alt := First (Alternatives (N)); while Present (Alt) loop - Resolve (Expression (Alt), Typ); + Alt_Expr := Expression (Alt); + Resolve (Alt_Expr, Typ); + Alt_Typ := Etype (Alt_Expr); + + -- When the expression is of a scalar subtype different from the + -- result subtype, then insert a conversion to ensure the generation + -- of a constraint check. + + if Is_Scalar_Type (Alt_Typ) and then Alt_Typ /= Typ then + Rewrite (Alt_Expr, Convert_To (Typ, Alt_Expr)); + Analyze_And_Resolve (Alt_Expr, Typ); + end if; + Next (Alt); end loop; @@ -6523,13 +6537,14 @@ package body Sem_Res is -- dynamically tagged must be known statically. if Is_Tagged_Type (Typ) and then not Is_Class_Wide_Type (Typ) then - Alt := First (Alternatives (N)); + Alt := First (Alternatives (N)); Is_Dyn := Is_Dynamically_Tagged (Expression (Alt)); while Present (Alt) loop if Is_Dynamically_Tagged (Expression (Alt)) /= Is_Dyn then - Error_Msg_N ("all or none of the dependent expressions " - & "can be dynamically tagged", N); + Error_Msg_N + ("all or none of the dependent expressions can be " + & "dynamically tagged", N); end if; Next (Alt); -- 2.30.2