From patchwork Mon Jun 14 10:50:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Ada] Inline_Always applied to a subprogram body without previous spec Date: Mon, 14 Jun 2010 00:50:33 -0000 From: Arnaud Charlet X-Patchwork-Id: 55518 Message-Id: <20100614105033.GA5126@adacore.com> To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg When a pragma Inline_Always is applied to a subprogram body, the compiler generates a spec to simplify subsequent inlinings of calls. The spec is created by copying the analyzed spec of the body. There is no need for a conformance spec between spec and body, and a conformance check may lead to spurious conformance errors due to constant folding of static aggregates in default expressions for formals. The following must compile quietly: procedure Inline is type R is record X, Y : Integer; end record; function Fun (It : R := (10, 20)) return Integer is begin return It.X + It.Y; end; pragma Inline_Always (Fun); begin null; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-14 Ed Schonberg * sem_ch6.adb (Analyze_Subprogram_Body): Do not check conformance when the spec has been generated for a body without spec that carries an Inline_Always pragma. Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 160720) +++ sem_ch6.adb (working copy) @@ -2086,6 +2086,15 @@ package body Sem_Ch6 is then Conformant := True; + -- Conversely, the spec may have been generated for specless body + -- with an inline pragma. + + elsif Comes_From_Source (N) + and then not Comes_From_Source (Spec_Id) + and then Has_Pragma_Inline (Spec_Id) + then + Conformant := True; + else Check_Conformance (Body_Id, Spec_Id,