From: Arnaud Charlet Date: Thu, 11 Apr 2013 12:46:16 +0000 (+0200) Subject: [multiple changes] X-Git-Tag: releases/gcc-4.9.0~6523 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=afb4a8cda0247500a0084508af16b7ccaf943c8b;p=thirdparty%2Fgcc.git [multiple changes] 2013-04-11 Ed Schonberg * 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. 2013-04-11 Vincent Celier * gnatname.adb: Minor comment fix. 2013-04-11 Vincent Celier * prj-makr.adb (Process_Directory): Create a new temporary file for each invocation of the compiler, in directory pointed by environment variable TMPDIR if it exists. 2013-04-11 Arnaud Charlet * gnat_ugn.texi: Minor editing/clean ups. From-SVN: r197781 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 3fe0913d26d7..918408fd8252 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,29 @@ +2013-04-11 Ed Schonberg + + * 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. + +2013-04-11 Vincent Celier + + * gnatname.adb: Minor comment fix. + +2013-04-11 Vincent Celier + + * prj-makr.adb (Process_Directory): Create a new temporary + file for each invocation of the compiler, in directory pointed + by environment variable TMPDIR if it exists. + +2013-04-11 Arnaud Charlet + + * gnat_ugn.texi: Minor editing/clean ups. + 2013-04-11 Ed Schonberg * sem_ch6.adb (Analyze_Null_Procedure): New subprogram, mostly diff --git a/gcc/ada/aspects.adb b/gcc/ada/aspects.adb index 8186e0ca7b42..2ef728c84769 100644 --- a/gcc/ada/aspects.adb +++ b/gcc/ada/aspects.adb @@ -220,6 +220,7 @@ package body Aspects is N_Subprogram_Body => True, N_Subprogram_Declaration => True, N_Subprogram_Renaming_Declaration => True, + N_Subprogram_Body_Stub => True, N_Subtype_Declaration => True, N_Task_Body => True, N_Task_Type_Declaration => True, diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 9ef3fe45645d..52107510c06b 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -3926,23 +3926,19 @@ files. It is possible to supply several file names on the same @command{gcc} command. This causes @command{gcc} to call the appropriate compiler for -each file. For example, the following command lists three separate +each file. For example, the following command lists two separate files to be compiled: @smallexample -$ gcc -c x.adb y.adb z.c +$ gcc -c x.adb y.adb @end smallexample @noindent calls @code{gnat1} (the Ada compiler) twice to compile @file{x.adb} and -@file{y.adb}, and @code{cc1} (the C compiler) once to compile @file{z.c}. -The compiler generates three object files @file{x.o}, @file{y.o} and -@file{z.o} and the two ALI files @file{x.ali} and @file{y.ali} from the -Ada compilations. Any switches apply to all the files ^listed,^listed.^ -@ifclear vms -except for -@option{-gnat@var{x}} switches, which apply only to Ada compilations. -@end ifclear +@file{y.adb}. +The compiler generates two object files @file{x.o} and @file{y.o} +and the two ALI files @file{x.ali} and @file{y.ali}. +Any switches apply to all the files ^listed,^listed.^ @node Switches for gcc @section Switches for @command{gcc} diff --git a/gcc/ada/gnatname.adb b/gcc/ada/gnatname.adb index 3c687315e535..56157ead462e 100644 --- a/gcc/ada/gnatname.adb +++ b/gcc/ada/gnatname.adb @@ -88,7 +88,7 @@ procedure Gnatname is Table_Initial => 10, Table_Increment => 100, Table_Name => "Gnatname.Arguments"); - -- Table to accumulate the foreign patterns + -- Table to accumulate directories and patterns package Preprocessor_Switches is new Table.Table (Table_Component_Type => String_Access, diff --git a/gcc/ada/par-ch6.adb b/gcc/ada/par-ch6.adb index 2243acea2eb3..42c2a8594e6b 100644 --- a/gcc/ada/par-ch6.adb +++ b/gcc/ada/par-ch6.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -684,6 +684,15 @@ package body Ch6 is Stub_Node := New_Node (N_Subprogram_Body_Stub, Sloc (Specification_Node)); Set_Specification (Stub_Node, Specification_Node); + + -- The specification has been parsed as part of a subprogram + -- declaration, and aspects have already been collected. + + if Is_Non_Empty_List (Aspects) then + Set_Parent (Aspects, Stub_Node); + Set_Aspect_Specifications (Stub_Node, Aspects); + end if; + Scan; -- past SEPARATE Pop_Scope_Stack; TF_Semicolon; diff --git a/gcc/ada/prj-makr.adb b/gcc/ada/prj-makr.adb index 3b869641f6a3..0ed805021f9a 100644 --- a/gcc/ada/prj-makr.adb +++ b/gcc/ada/prj-makr.adb @@ -38,6 +38,7 @@ with Prj.Util; use Prj.Util; with Sdefault; with Snames; use Snames; with Table; use Table; +with Tempdir; with Ada.Characters.Handling; use Ada.Characters.Handling; with GNAT.Directory_Operations; use GNAT.Directory_Operations; @@ -1235,6 +1236,7 @@ package body Prj.Makr is Success : Boolean; Saved_Output : File_Descriptor; Saved_Error : File_Descriptor; + Tmp_File : Path_Name_Type; begin -- If we don't have the path of the compiler yet, @@ -1256,19 +1258,17 @@ package body Prj.Makr is end if; end if; - -- If we don't have yet the file name of the - -- temporary file, get it now. + -- Create the temporary file - if Temp_File_Name = null then - Create_Temp_File (FD, Temp_File_Name); + Tempdir.Create_Temp_File (FD, Tmp_File); - if FD = Invalid_FD then - Prj.Com.Fail - ("could not create temporary file"); - end if; + if FD = Invalid_FD then + Prj.Com.Fail + ("could not create temporary file"); - Close (FD); - Delete_File (Temp_File_Name.all, Success); + else + Temp_File_Name := + new String'(Get_Name_String (Tmp_File)); end if; Args (Args'Last) := new String' @@ -1276,16 +1276,6 @@ package body Prj.Makr is Directory_Separator & Str (1 .. Last)); - -- Create the temporary file - - FD := Create_Output_Text_File - (Name => Temp_File_Name.all); - - if FD = Invalid_FD then - Prj.Com.Fail - ("could not create temporary file"); - end if; - -- Save the standard output and error Saved_Output := Dup (Standout); @@ -1331,7 +1321,8 @@ package body Prj.Makr is if not Is_Valid (File) then Prj.Com.Fail - ("could not read temporary file"); + ("could not read temporary file " & + Temp_File_Name.all); end if; Save_Last_Source_Index := Sources.Last; diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 41a7a2c3c055..6c19a551408e 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -1693,6 +1693,14 @@ package body Sem_Ch13 is else Insert_After (N, Aitem); + + -- Pre/Postconditions on stubs are analyzed at once, + -- because the proper body is analyzed next, and the + -- contract must be captured before the body. + + if Nkind (N) = N_Subprogram_Body_Stub then + Analyze (Aitem); + end if; end if; goto Continue; diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 8ac527d687ae..e34154c38c79 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -2681,10 +2681,11 @@ package body Sem_Ch6 is end if; -- Ada 2012 aspects may appear in a subprogram body, but only if there - -- is no previous spec. + -- is no previous spec. Ditto for a subprogram stub that does not have + -- a corresponding spec, but for which there may also be a spec_id. if Has_Aspects (N) then - if Present (Corresponding_Spec (N)) then + if Present (Spec_Id) then Error_Msg_N ("aspect specifications must appear in subprogram declaration", N); diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index c581fc6fed9c..32d3979728bf 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -2187,13 +2187,18 @@ package body Sem_Prag is ("aspect % requires ''Class for null procedure"); -- Pre/postconditions are legal on a subprogram body if it is not - -- a completion of a declaration. + -- a completion of a declaration. They are also legal on a stub + -- with no previous declarations (this is checked when processing + -- the corresponding aspects). elsif Nkind (PO) = N_Subprogram_Body and then Acts_As_Spec (PO) then null; + elsif Nkind (PO) = N_Subprogram_Body_Stub then + null; + elsif not Nkind_In (PO, N_Subprogram_Declaration, N_Expression_Function, N_Generic_Subprogram_Declaration,