From patchwork Wed Jun 23 09:15:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56618 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 1F841B6F14 for ; Wed, 23 Jun 2010 19:15:20 +1000 (EST) Received: (qmail 18888 invoked by alias); 23 Jun 2010 09:15:18 -0000 Received: (qmail 18871 invoked by uid 22791); 23 Jun 2010 09:15:16 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD 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; Wed, 23 Jun 2010 09:15:12 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 25A97CB025B; Wed, 23 Jun 2010 11:15:15 +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 rcm-SPz1c-CT; Wed, 23 Jun 2010 11:15:15 +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 0F9E8CB0249; Wed, 23 Jun 2010 11:15:15 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 5AB76D9BA8; Wed, 23 Jun 2010 11:15:12 +0200 (CEST) Date: Wed, 23 Jun 2010 11:15:12 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] PR ada/44633 Message-ID: <20100623091512.GA8211@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 This is a follow up from the previous change, to take into account properly all compiler switches in gnatmake -s switch, and fixes PR ada/44633 along the way. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-23 Vincent Celier PR ada/44633 * switch-m.adb (Normalize_Compiler_Switches): Take into account switches -gnatB, -gnatD=nn, -gnatG (incuding -gnatG=nn), -gnatI, -gnatl=file, -gnatS, -gnatjnn, -gnateI=nn and -gnatWx. Index: switch-m.adb =================================================================== --- switch-m.adb (revision 161263) +++ switch-m.adb (working copy) @@ -215,9 +215,9 @@ package body Switch.M is -- One-letter switches - when 'a' | 'A' | 'b' | 'c' | 'C' | 'D' | 'E' | 'f' | - 'F' | 'g' | 'h' | 'H' | 'l' | 'L' | 'n' | 'N' | - 'o' | 'O' | 'p' | 'P' | 'q' | 'Q' | 'r' | 's' | + when 'a' | 'A' | 'b' | 'B' | 'c' | 'C' | 'E' | 'f' | + 'F' | 'g' | 'h' | 'H' | 'I' | 'L' | 'n' | 'N' | + 'o' | 'p' | 'P' | 'q' | 'Q' | 'r' | 's' | 'S' | 't' | 'u' | 'U' | 'v' | 'x' | 'X' | 'Z' => Storing (First_Stored) := C; Add_Switch_Component @@ -226,10 +226,14 @@ package body Switch.M is -- One-letter switches followed by a positive number - when 'k' | 'm' | 'T' => + when 'D' | 'G' | 'j' | 'k' | 'm' | 'T' => Storing (First_Stored) := C; Last_Stored := First_Stored; + if Ptr <= Max and then Switch_Chars (Ptr) = '=' then + Ptr := Ptr + 1; + end if; + loop Ptr := Ptr + 1; exit when Ptr > Max @@ -268,68 +272,93 @@ package body Switch.M is when 'e' => - -- Store -gnateD, -gnatep=, -gnateG and -gnateS in the - -- ALI file. The other -gnate switches do not need to be - -- stored. + -- Some of the gnate... switches are not stored Storing (First_Stored) := 'e'; Ptr := Ptr + 1; - if Ptr > Max - or else (Switch_Chars (Ptr) /= 'D' - and then Switch_Chars (Ptr) /= 'G' - and then Switch_Chars (Ptr) /= 'p' - and then Switch_Chars (Ptr) /= 'S') - then + if Ptr > Max then Last := 0; return; - end if; - -- Processing for -gnateD + else + case Switch_Chars (Ptr) is - if Switch_Chars (Ptr) = 'D' then - Storing (First_Stored + 1 .. - First_Stored + Max - Ptr + 1) := - Switch_Chars (Ptr .. Max); - Add_Switch_Component - (Storing (Storing'First .. - First_Stored + Max - Ptr + 1)); + when 'D' => + Storing (First_Stored + 1 .. + First_Stored + Max - Ptr + 1) := + Switch_Chars (Ptr .. Max); + Add_Switch_Component + (Storing (Storing'First .. + First_Stored + Max - Ptr + 1)); + Ptr := Max + 1; - -- Processing for -gnatep= + when 'G' => + Ptr := Ptr + 1; + Add_Switch_Component ("-gnateG"); - elsif Switch_Chars (Ptr) = 'p' then - Ptr := Ptr + 1; + when 'I' => + Ptr := Ptr + 1; - if Ptr = Max then - Last := 0; - return; - end if; + declare + First : constant Positive := Ptr - 1; + begin + if Ptr <= Max and then + Switch_Chars (Ptr) = '=' + then + Ptr := Ptr + 1; + end if; + + while Ptr <= Max and then + Switch_Chars (Ptr) in '0' .. '9' + loop + Ptr := Ptr + 1; + end loop; + + Storing (First_Stored + 1 .. + First_Stored + Ptr - First) := + Switch_Chars (First .. Ptr - 1); + Add_Switch_Component + (Storing (Storing'First .. + First_Stored + Ptr - First)); + end; - if Switch_Chars (Ptr) = '=' then - Ptr := Ptr + 1; - end if; + when 'p' => + Ptr := Ptr + 1; - -- To normalize, always put a '=' after -gnatep. - -- Because that could lengthen the switch string, - -- declare a local variable. - - declare - To_Store : String (1 .. Max - Ptr + 9); - begin - To_Store (1 .. 8) := "-gnatep="; - To_Store (9 .. Max - Ptr + 9) := - Switch_Chars (Ptr .. Max); - Add_Switch_Component (To_Store); - end; + if Ptr = Max then + Last := 0; + return; + end if; + + if Switch_Chars (Ptr) = '=' then + Ptr := Ptr + 1; + end if; + + -- To normalize, always put a '=' after + -- -gnatep. Because that could lengthen the + -- switch string, declare a local variable. + + declare + To_Store : String (1 .. Max - Ptr + 9); + begin + To_Store (1 .. 8) := "-gnatep="; + To_Store (9 .. Max - Ptr + 9) := + Switch_Chars (Ptr .. Max); + Add_Switch_Component (To_Store); + end; - elsif Switch_Chars (Ptr) = 'G' then - Add_Switch_Component ("-gnateG"); + return; - elsif Switch_Chars (Ptr) = 'S' then - Add_Switch_Component ("-gnateS"); - end if; + when 'S' => + Ptr := Ptr + 1; + Add_Switch_Component ("-gnateS"); - return; + when others => + Last := 0; + return; + end case; + end if; when 'i' => Storing (First_Stored) := 'i'; @@ -360,6 +389,20 @@ package body Switch.M is return; end if; + -- -gnatl may be -gnatl= + + when 'l' => + Ptr := Ptr + 1; + + if Ptr > Max or else Switch_Chars (Ptr) /= '=' then + Add_Switch_Component ("-gnatl"); + + else + Add_Switch_Component + ("-gnatl" & Switch_Chars (Ptr .. Max)); + return; + end if; + -- -gnatR may be followed by '0', '1', '2' or '3', -- then by 's' @@ -395,6 +438,26 @@ package body Switch.M is Add_Switch_Component (Storing (Storing'First .. Last_Stored)); + -- -gnatWx, x = 'h'. 'u', 's', 'e', '8' or 'b' + + when 'W' => + Storing (First_Stored) := 'W'; + Ptr := Ptr + 1; + + if Ptr <= Max then + case Switch_Chars (Ptr) is + when 'h' | 'u' | 's' | 'e' | '8' | 'b' => + Storing (First_Stored + 1) := Switch_Chars (Ptr); + Add_Switch_Component + (Storing (Storing'First .. First_Stored + 1)); + Ptr := Ptr + 1; + + when others => + Last := 0; + return; + end case; + end if; + -- Multiple switches when 'V' | 'w' | 'y' =>