From patchwork Wed Aug 31 09:24:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 112481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 3C3FFB6F80 for ; Wed, 31 Aug 2011 19:25:12 +1000 (EST) Received: (qmail 4190 invoked by alias); 31 Aug 2011 09:25:09 -0000 Received: (qmail 4165 invoked by uid 22791); 31 Aug 2011 09:25:07 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 31 Aug 2011 09:24:53 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7056A2BAF86 for ; Wed, 31 Aug 2011 05:24:52 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jupGftA4U3MV for ; Wed, 31 Aug 2011 05:24:52 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 5EC2C2BAD62 for ; Wed, 31 Aug 2011 05:24:52 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 4211E3FEE8; Wed, 31 Aug 2011 05:24:52 -0400 (EDT) Date: Wed, 31 Aug 2011 05:24:52 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Subject: [Ada] Delete SCIL files in CodePeer mode Message-ID: <20110831092452.GA16529@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org When generating scil files (-gnatcC), we want to remove any old scil files corresponding to the main unit being compiled in case of errors, to avoid re-analyzing these old scil files. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-31 Arnaud Charlet * comperr.adb, comperr.ads, gnat1drv.adb (Delete_SCIL_Files): New subprogram. (Compiler_Abort, Gnat1drv): Call Delete_SCIL_Files in codepeer mode in case of a compilation error. Index: comperr.adb =================================================================== --- comperr.adb (revision 178358) +++ comperr.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, 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- -- @@ -27,20 +27,23 @@ -- error is detected. Calls to these routines cause termination of the -- current compilation with appropriate error output. -with Atree; use Atree; -with Debug; use Debug; -with Errout; use Errout; -with Gnatvsn; use Gnatvsn; -with Namet; use Namet; -with Opt; use Opt; -with Osint; use Osint; -with Output; use Output; -with Sinput; use Sinput; -with Sprint; use Sprint; -with Sdefault; use Sdefault; -with Targparm; use Targparm; -with Treepr; use Treepr; -with Types; use Types; +with Atree; use Atree; +with Debug; use Debug; +with Errout; use Errout; +with Gnatvsn; use Gnatvsn; +with Lib; use Lib; +with Namet; use Namet; +with Opt; use Opt; +with Osint; use Osint; +with Output; use Output; +with Sinfo; use Sinfo; +with Sinput; use Sinput; +with Sprint; use Sprint; +with Sdefault; use Sdefault; +with System.OS_Lib; use System.OS_Lib; +with Targparm; use Targparm; +with Treepr; use Treepr; +with Types; use Types; with Ada.Exceptions; use Ada.Exceptions; @@ -144,6 +147,10 @@ end if; end if; + if CodePeer_Mode then + Delete_SCIL_Files; + end if; + -- If any errors have already occurred, then we guess that the abort -- may well be caused by previous errors, and we don't make too much -- fuss about it, since we want to let programmer fix the errors first. @@ -422,9 +429,40 @@ Source_Dump; raise Unrecoverable_Error; end if; - end Compiler_Abort; + ----------------------- + -- Delete_SCIL_Files -- + ----------------------- + + procedure Delete_SCIL_Files is + Main : Node_Id; + Success : Boolean; + pragma Unreferenced (Success); + begin + -- If parsing was not successful, no Main_Unit is available, so return + -- immediately. + + if Main_Source_File = No_Source_File then + return; + end if; + + -- Retrieve unit name, and remove old versions of SCIL/.scil and + -- SCIL/__body.scil + + Main := Unit (Cunit (Main_Unit)); + + if Nkind (Main) = N_Subprogram_Body then + Get_Name_String (Chars (Defining_Unit_Name (Specification (Main)))); + else + Get_Name_String (Chars (Defining_Unit_Name (Main))); + end if; + + Delete_File ("SCIL/" & Name_Buffer (1 .. Name_Len) & ".scil", Success); + Delete_File + ("SCIL/" & Name_Buffer (1 .. Name_Len) & "__body.scil", Success); + end Delete_SCIL_Files; + ----------------- -- Repeat_Char -- ----------------- Index: comperr.ads =================================================================== --- comperr.ads (revision 178358) +++ comperr.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, 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- -- @@ -50,6 +50,9 @@ -- end exception (with possible message stored in TSD.Current_Excep, -- and negative (an unused value) for a GCC abort. + procedure Delete_SCIL_Files; + -- Delete SCIL files associated with the main unit + ------------------------------ -- Use of gnat_bug.box File -- ------------------------------ Index: gnat1drv.adb =================================================================== --- gnat1drv.adb (revision 178358) +++ gnat1drv.adb (working copy) @@ -842,6 +842,10 @@ Tree_Gen; end if; + if CodePeer_Mode then + Comperr.Delete_SCIL_Files; + end if; + Errout.Finalize (Last_Call => True); Exit_Program (E_Errors); end if;