From patchwork Mon Oct 4 15:08:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 66697 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 2F2C4B70D3 for ; Tue, 5 Oct 2010 02:08:55 +1100 (EST) Received: (qmail 14515 invoked by alias); 4 Oct 2010 15:08:45 -0000 Received: (qmail 14432 invoked by uid 22791); 4 Oct 2010 15:08:42 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD, WEIRD_QUOTING X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 04 Oct 2010 15:08:37 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 54EA0CB0244; Mon, 4 Oct 2010 17:08:35 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id B0Oywu3KvmLI; Mon, 4 Oct 2010 17:08:35 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id 34655CB0249; Mon, 4 Oct 2010 17:08:35 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 0471FD9BB4; Mon, 4 Oct 2010 17:08:34 +0200 (CEST) Date: Mon, 4 Oct 2010 17:08:33 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] gnatmake and invalid mains in attribute Main Message-ID: <20101004150833.GA733@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes 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 gnatmake now fails before attempting compilation if it is not invoked with mains on the command line, there are no language other than Ada in attribute Languages of the main project and one of the main specified in attribute Main of the main project does not exist or is a source of another project. The test for this is to invoke "gnatmake -P prj.gpr" on the following project with only source file main.adb in the directory: project Prj is for Main use ("main.adb", "junk.adb"); end Prj; This invocation of gnatmake should fail with: gnatmake: "junk.adb" is not a source of project Prj Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-04 Vincent Celier * make.adb (Gnatmake): When there are no foreign languages declared and a main in attribute Main of the main project does not exist or is a source of another project, fail immediately before attempting compilation. Index: make.adb =================================================================== --- make.adb (revision 164940) +++ make.adb (working copy) @@ -4468,29 +4468,41 @@ package body Make is -- language, all the Ada mains. while Value /= Prj.Nil_String loop - Get_Name_String - (Project_Tree.String_Elements.Table (Value).Value); - -- To know if a main is an Ada main, get its project. -- It should be the project specified on the command -- line. - if (not Foreign_Language) or else - Prj.Env.Project_Of - (Name_Buffer (1 .. Name_Len), - Main_Project, - Project_Tree) = - Main_Project - then - At_Least_One_Main := True; - Osint.Add_File - (Get_Name_String - (Project_Tree.String_Elements.Table - (Value).Value), - Index => - Project_Tree.String_Elements.Table - (Value).Index); - end if; + Get_Name_String + (Project_Tree.String_Elements.Table (Value).Value); + + declare + Main_Name : constant String := + Get_Name_String + (Project_Tree.String_Elements.Table + (Value).Value); + Proj : constant Project_Id := + Prj.Env.Project_Of + (Main_Name, Main_Project, Project_Tree); + begin + + if Proj = Main_Project then + + At_Least_One_Main := True; + Osint.Add_File + (Get_Name_String + (Project_Tree.String_Elements.Table + (Value).Value), + Index => + Project_Tree.String_Elements.Table + (Value).Index); + + elsif not Foreign_Language then + Make_Failed + ("""" & Main_Name & + """ is not a source of project " & + Get_Name_String (Main_Project.Display_Name)); + end if; + end; Value := Project_Tree.String_Elements.Table (Value).Next;