Bug 28305 - GNAT bug when inlining instance of a generic subprogram
Summary: GNAT bug when inlining instance of a generic subprogram
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 3.4.5
: P3 normal
Target Milestone: 4.4.0
Assignee: Samuel Tardieu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-07 15:49 UTC by Dewi Daniels
Modified: 2008-04-09 14:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-11-25 14:19:24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dewi Daniels 2006-07-07 15:49:08 UTC
A GNAT bug is detected whenever pragma Inline is applied to an instance of a generic subprogram and front-end inlining is activated (-gnatN).  The problem can be worked around by either applying the pragma Inline to the generic subprogram declaration or deactivating front-end inlining.

The test case I used is as follows:

gcc -c -gnatN test.ads

generic
  type T is private;
function A (Value : T) return T;

function A (Value : T) return T is
begin
  return Value;
end A;

with A;
pragma Elaborate_All (A);

function Test is new A (Integer);
pragma Inline (Test);
Comment 1 Laurent GUERBY 2006-07-11 11:03:48 UTC
Confirmed on 4.0, 4.1 releases and HEAD.

gcc -c -gnatN test.ads

+===========================GNAT BUG DETECTED==============================+
| 4.0.3 (x86_64-unknown-linux-gnu) Program_Error sinput.adb:404 explicit raise|
| Error detected at a.adb:2:1 [test.ads:5:1]                               |

+===========================GNAT BUG DETECTED==============================+
| 4.1.1 (x86_64-unknown-linux-gnu) Program_Error sinput.adb:404 explicit raise|
| Error detected at a.adb:2:1 [test.ads:5:1]                               |

+===========================GNAT BUG DETECTED==============================+
| 4.2.0 20060627 (experimental) (x86_64-unknown-linux-gnu) Program_Error sinput.adb:404 explicit raise|
| Error detected at a.adb:2:1 [test.ads:5:1]                               |

Comment 2 Samuel Tardieu 2007-11-17 12:34:34 UTC
Confirmed on 4.3.0 HEAD with a different (and strange) error message.

+===========================GNAT BUG DETECTED==============================+
| 4.3.0 20071114 (experimental) (i686-pc-linux-gnu) Program_Error sinput.adb:403 Current_Task referenced in entry body|
| Error detected at a.adb:2:1 [test.ads:5:1]                               |
Comment 3 Samuel Tardieu 2008-04-09 14:22:04 UTC
Subject: Bug 28305

Author: sam
Date: Wed Apr  9 14:21:18 2008
New Revision: 134142

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134142
Log:
    gcc/ada/
	PR ada/28305
	* sem_ch6.adb (Build_Body_To_Inline): Do not save and restore
	environment if generic instance is a top-level one.

    gcc/testsuite/
	PR ada/28305
	* gnat.dg/specs/fe_inlining.ads, gnat.dg/specs/fe_inlining_helper.ads,
	gnat.dg/specs/fe_inlining_helper.adb: New test.


Added:
    trunk/gcc/testsuite/gnat.dg/specs/fe_inlining.ads
    trunk/gcc/testsuite/gnat.dg/specs/fe_inlining_helper.adb
    trunk/gcc/testsuite/gnat.dg/specs/fe_inlining_helper.ads
Modified:
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/sem_ch6.adb
    trunk/gcc/testsuite/ChangeLog

Comment 4 Samuel Tardieu 2008-04-09 14:22:43 UTC
Fixed in SVN trunk.