diff options
author | Robert Dewar <dewar@adacore.com> | 2011-08-05 15:10:50 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-05 17:10:50 +0200 |
commit | dedac3eb7331f441f24b192fa0d9d1e1162f57ba (patch) | |
tree | dbf7d77eccd6d83effd5cc41a4d0d61e74a759c3 /gcc/ada/sem_ch11.adb | |
parent | 7c62a85a8dcec50e474c02525c5f165ad30cf2d9 (diff) | |
download | gcc-dedac3eb7331f441f24b192fa0d9d1e1162f57ba.zip gcc-dedac3eb7331f441f24b192fa0d9d1e1162f57ba.tar.gz gcc-dedac3eb7331f441f24b192fa0d9d1e1162f57ba.tar.bz2 |
par_sco.adb, [...]: Minor reformatting.
2011-08-05 Robert Dewar <dewar@adacore.com>
* par_sco.adb, sem_ch3.adb, scos.ads, a-iteint.ads, sem_ch12.adb,
a-cimutr.adb, a-cimutr.ads, sem_util.ads, sem_res.adb, a-fihema.adb,
sem_ch4.adb, lib-xref-alfa.adb, exp_disp.adb, a-comutr.adb,
a-comutr.ads, lib-xref.adb: Minor reformatting.
2011-08-05 Robert Dewar <dewar@adacore.com>
* sem_ch11.adb (Analyze_Raise_Statement): Kill assignment to formal
warning if there is an exception handler present.
From-SVN: r177451
Diffstat (limited to 'gcc/ada/sem_ch11.adb')
-rw-r--r-- | gcc/ada/sem_ch11.adb | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/gcc/ada/sem_ch11.adb b/gcc/ada/sem_ch11.adb index 30b5585..a393680 100644 --- a/gcc/ada/sem_ch11.adb +++ b/gcc/ada/sem_ch11.adb @@ -432,6 +432,7 @@ package body Sem_Ch11 is Exception_Id : constant Node_Id := Name (N); Exception_Name : Entity_Id := Empty; P : Node_Id; + Par : Node_Id; begin Check_SPARK_Restriction ("raise statement is not allowed", N); @@ -443,9 +444,9 @@ package body Sem_Ch11 is Check_Restriction (No_Exceptions, N); end if; - -- Check for useless assignment to OUT or IN OUT scalar immediately - -- preceding the raise. Right now we only look at assignment statements, - -- we could do more. + -- Check for useless assignment to OUT or IN OUT scalar preceding the + -- raise. Right now we only look at assignment statements, we could do + -- more. if Is_List_Member (N) then declare @@ -455,21 +456,49 @@ package body Sem_Ch11 is begin P := Prev (N); + -- Skip past null statements and pragmas + + while Present (P) + and then Nkind_In (P, N_Null_Statement, N_Pragma) + loop + P := Prev (P); + end loop; + + -- See if preceding statement is an assignment + if Present (P) and then Nkind (P) = N_Assignment_Statement then L := Name (P); + -- Give warning for assignment to scalar formal + if Is_Scalar_Type (Etype (L)) and then Is_Entity_Name (L) and then Is_Formal (Entity (L)) then - Error_Msg_N - ("?assignment to pass-by-copy formal may have no effect", - P); - Error_Msg_N - ("\?RAISE statement may result in abnormal return" & - " (RM 6.4.1(17))", P); + -- Don't give warning if we are covered by an exception + -- handler, since this may result in false positives, since + -- the handler may handle the exception and return normally. + + -- First find enclosing sequence of statements + + Par := N; + loop + Par := Parent (Par); + exit when Nkind (Par) = N_Handled_Sequence_Of_Statements; + end loop; + + -- See if there is a handler, give message if not + + if No (Exception_Handlers (Par)) then + Error_Msg_N + ("?assignment to pass-by-copy formal " & + "may have no effect", P); + Error_Msg_N + ("\?RAISE statement may result in abnormal return" & + " (RM 6.4.1(17))", P); + end if; end if; end if; end; |