[Ada] Tweak the warning about missing local raises

Message ID 20211011133959.GA1519208@adacore.com
State Committed
Commit 4a0d6b70e3877728772b177e35b0a429d5501698
Headers
Series [Ada] Tweak the warning about missing local raises |

Commit Message

Pierre-Marie de Rodat Oct. 11, 2021, 1:39 p.m. UTC
  This prevents the warning from being given when there may still be regular
exception handlers in the code, although some of them have been turned into
local raises, by querying the predicate that determines whether such regular
handlers are removed or not in the front-end.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* gcc-interface/trans.c (gnat_to_gnu) <N_Pop_Constraint_Error_Label>:
	Given the warning only if No_Exception_Propagation is active.
	<N_Pop_Storage_Error_Label>: Likewise.
	<N_Pop_Program_Error_Label>: Likewise.
  

Patch

diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -7872,21 +7872,24 @@  gnat_to_gnu (Node_Id gnat_node)
     case N_Pop_Constraint_Error_Label:
       gnat_temp = gnu_constraint_error_label_stack.pop ();
       if (Present (gnat_temp)
-	  && !TREE_USED (gnat_to_gnu_entity (gnat_temp, NULL_TREE, false)))
+	  && !TREE_USED (gnat_to_gnu_entity (gnat_temp, NULL_TREE, false))
+	  && No_Exception_Propagation_Active ())
 	Warn_If_No_Local_Raise (gnat_temp);
       break;
 
     case N_Pop_Storage_Error_Label:
       gnat_temp = gnu_storage_error_label_stack.pop ();
       if (Present (gnat_temp)
-	  && !TREE_USED (gnat_to_gnu_entity (gnat_temp, NULL_TREE, false)))
+	  && !TREE_USED (gnat_to_gnu_entity (gnat_temp, NULL_TREE, false))
+	  && No_Exception_Propagation_Active ())
 	Warn_If_No_Local_Raise (gnat_temp);
       break;
 
     case N_Pop_Program_Error_Label:
       gnat_temp = gnu_program_error_label_stack.pop ();
       if (Present (gnat_temp)
-	  && !TREE_USED (gnat_to_gnu_entity (gnat_temp, NULL_TREE, false)))
+	  && !TREE_USED (gnat_to_gnu_entity (gnat_temp, NULL_TREE, false))
+	  && No_Exception_Propagation_Active ())
 	Warn_If_No_Local_Raise (gnat_temp);
       break;