This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
In Ada 2012, aspect specifications can appear on subprogram body stubs, as long as there is no previous corresponding subprogram declaration. This patch handles properly aspects on such stubs, and rejects aspects when a previous subprogram declaration exists. executing the following: gnatmake -q -Paspects main Must print: Done --- project Aspects is package Compiler is for Default_Switches ("ada") use ("-gnat12", "-gnata"); end Compiler; for Main use ("main.adb"); end Aspects; --- with Pkg; with Ada.Text_IO; use Ada.Text_IO; with Ada.Assertions; use Ada.Assertions; procedure Main is begin begin Pkg.Sep1 (0); Put_Line ("ERROR 1, an exception should be raised"); exception when Assertion_Error => null; end; begin Pkg.Sep2 (1); Put_Line ("ERROR 2, an exception should be raised (or compilation error)"); exception when Assertion_Error => null; end; begin Pkg.Call_Sep3 (0); Put_Line ("ERROR 3, an exception should be raised"); exception when Assertion_Error => null; end; Put_Line ("Done"); end Main; --- package Pkg is procedure Sep1 (I : Integer) with Pre => I > 0; procedure Sep2 (I : Integer) with Pre => I > 10; procedure Call_Sep3 (I : Integer); end Pkg; --- package body Pkg is procedure Sep1 (I : Integer) is separate; procedure Sep2 (I : Integer) is separate; procedure Sep3 (I : Integer) with Pre => I > 10 is separate; procedure Call_Sep3 (I : Integer) is begin Sep3 (I); end; end Pkg; --- separate (Pkg) procedure Sep1 (I : Integer) is begin null; end Sep1; --- separate (Pkg) procedure Sep2 (I : Integer) is begin null; end Sep2; --- separate (Pkg) procedure Sep3 (I : Integer) is begin null; end Sep3; Tested on x86_64-pc-linux-gnu, committed on trunk 2013-04-11 Ed Schonberg <schonberg@adacore.com> * par-ch6.adb (P_Subprogram): Attach aspects to subprogram stub. * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Allow aspects on subprogram stubs. * sem_ch13.adb (Analyze_Aspect_Specifications): Analyze generated pre/post pragmas at once before analyzing the proper body. * sem_prag.adb (Chain_PPC): Handle pragma that comes from an aspect on a subprogram stub. * aspects.adb: Aspect specifications can appear on a subprogram_Body_Stub.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |