summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_res.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-04 09:18:12 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-04 09:18:12 +0000
commitf1f3250a6c57dbc6e595773adf43a5181dfae467 (patch)
treea2002af452b1527d28b25193a57cac52564eb312 /gcc/ada/sem_res.adb
parent77f9be2dab5055773bb3411b708c79f2a76c3590 (diff)
downloadgcc-f1f3250a6c57dbc6e595773adf43a5181dfae467.tar.gz
2011-08-04 Yannick Moy <moy@adacore.com>
* par-ch13.adb (Aspect_Specifications_Present): recognize "with Identifier'Class =>" as an aspect, so that a meaningful warning is issued in Strict mode. * par.adb: Fix typos in comments. 2011-08-04 Yannick Moy <moy@adacore.com> * sem_attr.adb (Result): modify error message to take into account Post aspect when compiling Ada 2012 (or newer) code. 2011-08-04 Nicolas Roche <roche@adacore.com> * env.c (__gnat_clearenv): Avoid use of dynamic size array in order to remove need for GCC exceptions. 2011-08-04 Vincent Celier <celier@adacore.com> * makeutl.adb (Do_Complete): Call Debug_Output with the name of the project, not the source file name. * prj.adb (Find_Sources.Look_For_Sources): If the source has been excluded, continue looking. This excluded source will only be returned if there is no other source with the same base name that is not locally removed. 2011-08-04 Ed Schonberg <schonberg@adacore.com> * sem_res.adb (Resolve_Intrinsic_Operator): if the result type is private and one of the operands is a real literal, use a qualified expression rather than a conversion which is not meaningful to the back-end. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177342 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r--gcc/ada/sem_res.adb35
1 files changed, 32 insertions, 3 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index f5bf3689912..294322df06a 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -5261,6 +5261,9 @@ package body Sem_Res is
-- decrease false positives, without losing too many good
-- warnings. The idea is that these previous statements
-- may affect global variables the procedure depends on.
+ -- We also exclude raise statements, that may arise from
+ -- constraint checks and are probably unrelated to the
+ -- intended control flow.
if Nkind (N) = N_Procedure_Call_Statement
and then Is_List_Member (N)
@@ -5270,7 +5273,10 @@ package body Sem_Res is
begin
P := Prev (N);
while Present (P) loop
- if Nkind (P) /= N_Assignment_Statement then
+ if not Nkind_In (P,
+ N_Assignment_Statement,
+ N_Raise_Constraint_Error)
+ then
exit Scope_Loop;
end if;
@@ -7026,6 +7032,28 @@ package body Sem_Res is
Arg1 : Node_Id;
Arg2 : Node_Id;
+ function Convert_Operand (Opnd : Node_Id) return Node_Id;
+ -- If the operand is a literal, it cannot be the expression in a
+ -- conversion. Use a qualified expression instead.
+
+ function Convert_Operand (Opnd : Node_Id) return Node_Id is
+ Loc : constant Source_Ptr := Sloc (Opnd);
+ Res : Node_Id;
+ begin
+ if Nkind_In (Opnd, N_Integer_Literal, N_Real_Literal) then
+ Res :=
+ Make_Qualified_Expression (Loc,
+ Subtype_Mark => New_Occurrence_Of (Btyp, Loc),
+ Expression => Relocate_Node (Opnd));
+ Analyze (Res);
+
+ else
+ Res := Unchecked_Convert_To (Btyp, Opnd);
+ end if;
+
+ return Res;
+ end Convert_Operand;
+
begin
-- We must preserve the original entity in a generic setting, so that
-- the legality of the operation can be verified in an instance.
@@ -7048,12 +7076,13 @@ package body Sem_Res is
-- type.
if Is_Private_Type (Typ) then
- Arg1 := Unchecked_Convert_To (Btyp, Left_Opnd (N));
+ Arg1 := Convert_Operand (Left_Opnd (N));
+ -- Unchecked_Convert_To (Btyp, Left_Opnd (N));
if Nkind (N) = N_Op_Expon then
Arg2 := Unchecked_Convert_To (Standard_Integer, Right_Opnd (N));
else
- Arg2 := Unchecked_Convert_To (Btyp, Right_Opnd (N));
+ Arg2 := Convert_Operand (Right_Opnd (N));
end if;
if Nkind (Arg1) = N_Type_Conversion then