* [Ada] Spurious error in nested generic containing expression function
@ 2017-09-29 13:05 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2017-09-29 13:05 UTC (permalink / raw)
To: gcc-patches; +Cc: Ed Schonberg
[-- Attachment #1: Type: text/plain, Size: 832 bytes --]
This patch removes spurious visibility errors from the instantiation of a
generic package nested within another generic, when the inner package
contains an expression function that is the completion of a visible
function of that package, and the expression includes an object of a
tagged type local to the generic.
No small example available.
Tested on x86_64-pc-linux-gnu, committed on trunk
2017-09-29 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (Analyze_Expression_Function): Do not emit freeze nodes
for types in expression if the function is within a generic unit.
* sem_res.adb (Resolve): In a generic context do not freeze an
expression, unless it is an entity. This exception is solely for the
purpose of detecting illegal uses of deferred constants in generic
units.
* sem_res.adb: Minor reformatting.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1477 bytes --]
Index: sem_ch6.adb
===================================================================
--- sem_ch6.adb (revision 253283)
+++ sem_ch6.adb (working copy)
@@ -568,8 +568,11 @@
-- Note that we cannot defer this freezing to the analysis of the
-- expression itself, because a freeze node might appear in a nested
-- scope, leading to an elaboration order issue in gigi.
+ -- As elsewhere, we do not emit freeze nodes within a generic unit.
- Freeze_Expr_Types (Def_Id);
+ if not Inside_A_Generic then
+ Freeze_Expr_Types (Def_Id);
+ end if;
-- For navigation purposes, indicate that the function is a body
Index: sem_res.adb
===================================================================
--- sem_res.adb (revision 253283)
+++ sem_res.adb (working copy)
@@ -3070,8 +3070,15 @@
-- Here we are resolving the corresponding expanded body, so we do
-- need to perform normal freezing.
- Freeze_Expression (N);
+ -- As elsewhere we do not emit freeze node within a generic. We make
+ -- an exception for entities that are expressions, only to detect
+ -- misuses of deferred constants and preserve the output of various
+ -- tests.
+ if not Inside_A_Generic or else Is_Entity_Name (N) then
+ Freeze_Expression (N);
+ end if;
+
-- Now we can do the expansion
Expand (N);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-09-29 13:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29 13:05 [Ada] Spurious error in nested generic containing expression function Pierre-Marie de Rodat
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).