public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Spurious error on deferred constant in expression function
@ 2017-04-25  8:23 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2017-04-25  8:23 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ed Schonberg

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

This patch removes a spurious error on a deferred constant that appears
within an expression function, when the expression is being frozen by the
presence of its generated body. Such bodies are not a freeze point unless
they are completions.

The following must compile quietly:

---
package P is
   package S is
      type T is private;
      No_T : constant T;
      function Is_Null (A_T : T) return Boolean is (A_T = No_T);
   private
      type T is null record;
      No_T : constant T := (null record);
   end;
end P;

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

2017-04-25  Ed Schonberg  <schonberg@adacore.com>

	* freeze.adb (Check_Expression_Function): Do not check for the
	use of deferred constants if the freezing of the expression
	function is triggered by its generated body, rather than a
	premature use.


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

Index: freeze.adb
===================================================================
--- freeze.adb	(revision 247140)
+++ freeze.adb	(working copy)
@@ -1384,8 +1384,12 @@
    begin
       Decl := Original_Node (Unit_Declaration_Node (Nam));
 
+      --  The subprogram body created for the expression function is not
+      --  itself a freeze point.
+
       if Scope (Nam) = Current_Scope
         and then Nkind (Decl) = N_Expression_Function
+        and then Nkind (N) /= N_Subprogram_Body
       then
          Check_Deferred (Expression (Decl));
       end if;

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

only message in thread, other threads:[~2017-04-25  8:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-25  8:23 [Ada] Spurious error on deferred constant in expression function 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).