[Ada] Spurious restriction violation on Ghost code
authorEd Schonberg <schonberg@adacore.com>
Thu, 10 Oct 2019 15:23:14 +0000 (15:23 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Thu, 10 Oct 2019 15:23:14 +0000 (15:23 +0000)
2019-10-10  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* exp_ch6.adb (Expand_Simple_Function_Return_Statement): If the
function to which the return statement applies is an
Ignored_Ghost_Function, do not indicate that it uses the
secondary stack when the return type is unconstrained.

From-SVN: r276814

gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb

index 745c7b5..7579bb3 100644 (file)
@@ -1,15 +1,6 @@
-2019-10-10  Bob Duff  <duff@adacore.com>
+2019-10-10  Ed Schonberg  <schonberg@adacore.com>
 
-       * libgnat/a-cbdlli.adb, libgnat/a-cbhama.adb,
-       libgnat/a-cbhase.adb, libgnat/a-cbmutr.adb,
-       libgnat/a-cborma.adb, libgnat/a-cborse.adb,
-       libgnat/a-cdlili.adb, libgnat/a-cidlli.adb,
-       libgnat/a-cihama.adb, libgnat/a-cihase.adb,
-       libgnat/a-cimutr.adb, libgnat/a-ciorma.adb,
-       libgnat/a-ciorse.adb, libgnat/a-cobove.adb,
-       libgnat/a-cohama.adb, libgnat/a-cohase.adb,
-       libgnat/a-coinve.adb, libgnat/a-comutr.adb,
-       libgnat/a-conhel.adb, libgnat/a-convec.adb,
-       libgnat/a-coorma.adb, libgnat/a-coorse.adb (Reference,
-       Constant_Reference): Use Busy instead of Lock, so we forbid
-       tampering with cursors, rather than tampering with elements.
\ No newline at end of file
+       * exp_ch6.adb (Expand_Simple_Function_Return_Statement): If the
+       function to which the return statement applies is an
+       Ignored_Ghost_Function, do not indicate that it uses the
+       secondary stack when the return type is unconstrained.
\ No newline at end of file
index c569ca3..b311322 100644 (file)
@@ -6895,7 +6895,12 @@ package body Exp_Ch6 is
       elsif Is_Thunk (Current_Scope) and then Is_Incomplete_Type (Exptyp) then
          return;
 
-      elsif not Requires_Transient_Scope (R_Type) then
+      --  A return statement from a Ghost function does not use the secondary
+      --  stack (or any other one).
+
+      elsif not Requires_Transient_Scope (R_Type)
+        or else Is_Ignored_Ghost_Entity (Scope_Id)
+      then
 
          --  Mutable records with variable-length components are not returned
          --  on the sec-stack, so we need to make sure that the back end will