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);
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] |
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] |
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
Fixed in SVN trunk.