summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-20 10:44:17 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-20 10:44:17 +0000
commita0be350a4e31d09febd38fee64f3ad0e57d5ea01 (patch)
treea74e6596573ee26603c7bef7d84f7db2858afd8c
parentb80646f049a529e178a97793714aed337a49abcd (diff)
downloadgcc-a0be350a4e31d09febd38fee64f3ad0e57d5ea01.tar.gz
2016-04-20 Yannick Moy <moy@adacore.com>
* sem_ch4.adb: Fix typos in comments. * sem_res.adb (Resolve_Case_Expression): Fix type of case alternatives. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235263 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/sem_ch4.adb4
-rw-r--r--gcc/ada/sem_res.adb27
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 <moy@adacore.com>
+
+ * sem_ch4.adb: Fix typos in comments.
+ * sem_res.adb (Resolve_Case_Expression): Fix type of case alternatives.
+
2016-04-20 Ed Schonberg <schonberg@adacore.com>
* 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);