public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Crash in compile-only mode with dynamic predicates.
@ 2015-10-20 10:28 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2015-10-20 10:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ed Schonberg

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

This patch fixes a compiler abort on a program with a type that has defined
dynamic predicate and a call to a procedure with a parameter of that type,
when the program is compiled with -gnatc.

The following must compile quietly:

gcc -c -gnatc p-q.adb

---
with Unchecked_Conversion;
package P is
   function Is_Valid_Name (Item : String) return Boolean;
   subtype Name_T is String with Dynamic_Predicate => Is_Valid_Name (Name_T);

   generic
      type T is private;
   package G is
    function Conv is new Unchecked_Conversion (Source => T, Target => Integer);
   end G;
end P;
---
package P.Q is
   type Rec is record
      B : Integer;
   end record;

   package My_G is new G (Rec);
   procedure Proc (Name : Name_T);
end P.Q;
---
package body P.Q is
   procedure Proc (Name : Name_T) is
   begin
      null;
   end;
end P.Q;

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

2015-10-20  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Generate freeze
	node for subprogram in Compile_Only mode.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1494 bytes --]

Index: sem_ch6.adb
===================================================================
--- sem_ch6.adb	(revision 229023)
+++ sem_ch6.adb	(working copy)
@@ -3215,18 +3215,17 @@
          --  the freeze actions that include the bodies. In particular, extra
          --  formals for accessibility or for return-in-place may need to be
          --  generated. Freeze nodes, if any, are inserted before the current
-         --  body. These freeze actions are also needed in ASIS mode to enable
-         --  the proper back-annotations.
+         --  body. These freeze actions are also needed in ASIS mode and in
+         --  Compile_Only mode to enable the proper back-end type annotations.
+         --  They are necessary in any case to insure order of elaboration
+         --  in gigi.
 
          if not Is_Frozen (Spec_Id)
-           and then (Expander_Active or ASIS_Mode)
+           and then (Expander_Active
+                       or else ASIS_Mode
+                       or else (Operating_Mode = Check_Semantics
+                                  and then Serious_Errors_Detected = 0))
          then
-            --  Force the generation of its freezing node to ensure proper
-            --  management of access types in the backend.
-
-            --  This is definitely needed for some cases, but it is not clear
-            --  why, to be investigated further???
-
             Set_Has_Delayed_Freeze (Spec_Id);
             Freeze_Before (N, Spec_Id);
          end if;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-10-20 10:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-20 10:28 [Ada] Crash in compile-only mode with dynamic predicates Arnaud Charlet

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).