aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch4.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2013-04-25 12:28:45 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2013-04-25 12:28:45 +0200
commit0812b84e77d5b5d187ea4c75841e4569f016612f (patch)
tree1709a49cd2beccc5cb64451b8470a07e5801ea9d /gcc/ada/sem_ch4.adb
parent1355d3738f0cabb2029899b905305e728d75674a (diff)
downloadgcc-0812b84e77d5b5d187ea4c75841e4569f016612f.zip
gcc-0812b84e77d5b5d187ea4c75841e4569f016612f.tar.gz
gcc-0812b84e77d5b5d187ea4c75841e4569f016612f.tar.bz2
[multiple changes]
2013-04-25 Robert Dewar <dewar@adacore.com> * debug.adb: Remove d.X and d.Y entries and documentation. * exp_ch4.adb (Expand_N_If_Expression): Remove special code used if expression with actions not available (now always available). (Expand_Short_Circuit_Operator): Same change. * gnat1drv.adb (Adjust_Global_Switches) Remove setting Use_Expression_With_Actions flag, since this is now obsolete. * opt.ads (Use_Expression_Actions): Removed (always True now). * sinfo.ads: Minor comment updates. 2013-04-25 Ed Schonberg <schonberg@adacore.com> * sem_ch12.adb (Check_Generic_Actuals): If an actual is an array subtype whose base type is currently private, install full view when compiling instance body. 2013-04-25 Ed Schonberg <schonberg@adacore.com> * sem_disp.adb (Check_Dispatching_Operation): Refine checks for AI05-0125: the check for a hidden primitive that may be overridden by the new declaration is only performed if the declaration comes from source, and it must carry an explicit overriding indicator. 2013-04-25 Hristian Kirtchev <kirtchev@adacore.com> * einfo.adb (Abstract_States): The attribute now applies to generic packages. * sem_ch3.adb (Analyze_Object_Declaration): Check whether an object declaration introduces an illegal hidden state. * sem_prag.adb (Analyze_Abstract_State): Check whether a state declaration introduces an illegal hidden state. * sem_util.ads, sem_util.adb (Check_No_Hidden_State): New routine. 2013-04-25 Ed Schonberg <schonberg@adacore.com> * exp_ch6.adb (Is_Build_In_Place_Function_Call): The call may be to a protected function, in which case the name in the call is a selected component. 2013-04-25 Hristian Kirtchev <kirtchev@adacore.com> * sem_ch4.adb (Analyze_Quantified_Expression): Warn on a suspicious use of quantifier "some" when "all" was meant. (No_Else_Or_Trivial_True): New routine. From-SVN: r198287
Diffstat (limited to 'gcc/ada/sem_ch4.adb')
-rw-r--r--gcc/ada/sem_ch4.adb45
1 files changed, 42 insertions, 3 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index eb36597..2fa9c5a 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -3501,13 +3501,15 @@ package body Sem_Ch4 is
-----------------------------------
procedure Analyze_Quantified_Expression (N : Node_Id) is
- QE_Scop : Entity_Id;
-
function Is_Empty_Range (Typ : Entity_Id) return Boolean;
-- If the iterator is part of a quantified expression, and the range is
-- known to be statically empty, emit a warning and replace expression
-- with its static value. Returns True if the replacement occurs.
+ function No_Else_Or_Trivial_True (If_Expr : Node_Id) return Boolean;
+ -- Determine whether if expression If_Expr lacks an else part or if it
+ -- has one, it evaluates to True.
+
--------------------
-- Is_Empty_Range --
--------------------
@@ -3545,6 +3547,25 @@ package body Sem_Ch4 is
end if;
end Is_Empty_Range;
+ -----------------------------
+ -- No_Else_Or_Trivial_True --
+ -----------------------------
+
+ function No_Else_Or_Trivial_True (If_Expr : Node_Id) return Boolean is
+ Else_Expr : constant Node_Id :=
+ Next (Next (First (Expressions (If_Expr))));
+ begin
+ return
+ No (Else_Expr)
+ or else (Compile_Time_Known_Value (Else_Expr)
+ and then Is_True (Expr_Value (Else_Expr)));
+ end No_Else_Or_Trivial_True;
+
+ -- Local variables
+
+ Cond : constant Node_Id := Condition (N);
+ QE_Scop : Entity_Id;
+
-- Start of processing for Analyze_Quantified_Expression
begin
@@ -3579,11 +3600,29 @@ package body Sem_Ch4 is
Preanalyze (Loop_Parameter_Specification (N));
end if;
- Preanalyze_And_Resolve (Condition (N), Standard_Boolean);
+ Preanalyze_And_Resolve (Cond, Standard_Boolean);
End_Scope;
Set_Etype (N, Standard_Boolean);
+
+ -- Diagnose a possible misuse of the "some" existential quantifier. When
+ -- we have a quantified expression of the form
+ --
+ -- for some X => (if P then Q [else True])
+ --
+ -- the if expression will not hold and render the quantified expression
+ -- trivially True.
+
+ if Formal_Extensions
+ and then not All_Present (N)
+ and then Nkind (Cond) = N_If_Expression
+ and then No_Else_Or_Trivial_True (Cond)
+ then
+ Error_Msg_N ("?suspicious expression", N);
+ Error_Msg_N ("\\did you mean (for all X ='> (if P then Q))", N);
+ Error_Msg_N ("\\or (for some X ='> P and then Q) instead'?", N);
+ end if;
end Analyze_Quantified_Expression;
-------------------