* [Ada] Spurious inlining error with function completed by an expression function
@ 2016-04-18 9:52 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2016-04-18 9:52 UTC (permalink / raw)
To: gcc-patches; +Cc: Ed Schonberg
[-- Attachment #1: Type: text/plain, Size: 993 bytes --]
This patch fixes a spurious error on a call to an expression function whose
expression is a call to a function whose full declaration is another expression
function, when compiling with optimization and inlining warnings enabled.
The following must compile quietly:
gcc -c p.adb -gnatn -O -fdump-tree-optimized
grep is_two p.adb.*.optimized
---
with Q; use Q;
procedure P is
begin
if not Is_Two (2) then
raise Program_Error;
end if;
end;
---
with R; use R;
package Q is
function Is_Two (I : Integer) return Boolean;
private
function Is_Two (I : Integer) return Boolean is (Is_One (I - 1));
end Q;
---
package R is
function Is_One (I : Integer) return Boolean is (I = 1);
pragma Inline_Always (Is_One);
end R;
Tested on x86_64-pc-linux-gnu, committed on trunk
2016-04-18 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (Analyze_Expression_Function): Set Inlined flag
on the entity of a subprogram declaration that is completed by
an expression function.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1182 bytes --]
Index: sem_ch6.adb
===================================================================
--- sem_ch6.adb (revision 235093)
+++ sem_ch6.adb (working copy)
@@ -362,7 +362,7 @@
Set_Is_Inlined (Prev);
-- If the expression function is a completion, the previous declaration
- -- must come from source. We know already that appears in the current
+ -- must come from source. We know already that it appears in the current
-- scope. The entity itself may be internally created if within a body
-- to be inlined.
@@ -371,6 +371,7 @@
and then not Is_Formal_Subprogram (Prev)
then
Set_Has_Completion (Prev, False);
+ Set_Is_Inlined (Prev);
-- An expression function that is a completion freezes the
-- expression. This means freezing the return type, and if it is
@@ -411,7 +412,6 @@
-- Not clear that the backend can inline it in this case ???
if Has_Completion (Prev) then
- Set_Is_Inlined (Prev);
-- The formals of the expression function are body formals,
-- and do not appear in the ali file, which will only contain
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-18 9:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-18 9:52 [Ada] Spurious inlining error with function completed by an 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).