[Ada] Pragma No_Return on generic units

Arnaud Charlet charlet@adacore.com
Wed Sep 6 10:02:00 GMT 2017


This patch ensures that if a pragma No_Return applies to a generic subprogram ,
all its instantiations are treated as No_Return subprograms as well.

Tested in ACATS 4.1D C651001.

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

2017-09-06  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch12.adb (Analyze_Subprogram_Instantiation): Propagate
	No_Return flag to instance if pragma applies to generic unit. This
	must be done explicitly because the pragma does not appear
	directly in the generic declaration (unlike the corresponding
	aspect specification).

-------------- next part --------------
Index: sem_ch12.adb
===================================================================
--- sem_ch12.adb	(revision 251753)
+++ sem_ch12.adb	(working copy)
@@ -5382,6 +5382,15 @@
          Set_Has_Pragma_Inline (Act_Decl_Id, Has_Pragma_Inline (Gen_Unit));
          Set_Has_Pragma_Inline (Anon_Id,     Has_Pragma_Inline (Gen_Unit));
 
+         --  Propagate No_Return if pragma applied to generic unit. This must
+         --  be done explicitly because pragma does not appear in generic
+         --  declaration (unlike the aspect case).
+
+         if No_Return (Gen_Unit) then
+            Set_No_Return (Act_Decl_Id);
+            Set_No_Return (Anon_Id);
+         end if;
+
          Set_Has_Pragma_Inline_Always
            (Act_Decl_Id, Has_Pragma_Inline_Always (Gen_Unit));
          Set_Has_Pragma_Inline_Always


More information about the Gcc-patches mailing list