public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Steve Baird <baird@adacore.com>
Subject: [Ada] No Storage_Error for an oversized disabled ghost array object
Date: Wed, 18 Sep 2019 08:39:00 -0000	[thread overview]
Message-ID: <20190918083944.GA145055@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 647 bytes --]

In some cases where the size computation for an object declaration will
unconditionally overflow, the FE generates code to raise Storage_Error
at the point of the object declaration (and may generate an associated
warning). Don't do this if the object declaration is an ignored (i.e.,
disabled) ghost declaration.

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

2019-09-18  Steve Baird  <baird@adacore.com>

gcc/ada/

	* freeze.adb (Freeze_Object_Declaration): Do not call
	Check_Large_Modular_Array when the object declaration being
	frozen is an ignored ghost entity.

gcc/testsuite/

	* gnat.dg/ghost7.adb, gnat.dg/ghost7.ads: New testcase.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1028 bytes --]

--- gcc/ada/freeze.adb
+++ gcc/ada/freeze.adb
@@ -3569,7 +3569,8 @@ package body Freeze is
             Error_Msg_N ("\??use explicit size clause to set size", E);
          end if;
 
-         if Is_Array_Type (Typ) then
+         --  Declaring a too-big array in disabled ghost code is OK
+         if Is_Array_Type (Typ) and then not Is_Ignored_Ghost_Entity (E) then
             Check_Large_Modular_Array (Typ);
          end if;
       end Freeze_Object_Declaration;

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/ghost7.adb
@@ -0,0 +1,6 @@
+--  { dg-do compile }
+--  { dg-options "-gnatwa" }
+
+package body Ghost7 is
+   procedure Dummy is null;
+end Ghost7;

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/ghost7.ads
@@ -0,0 +1,8 @@
+pragma Restrictions (No_Exception_Propagation);
+
+package Ghost7 is
+   type Word64 is mod 2**64;
+   type My_Array_Type is array (Word64) of Boolean;
+   My_Array : My_Array_Type with Ghost;
+   procedure Dummy;
+end Ghost7;
\ No newline at end of file


                 reply	other threads:[~2019-09-18  8:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190918083944.GA145055@adacore.com \
    --to=derodat@adacore.com \
    --cc=baird@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).