From patchwork Fri Sep 8 13:31:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 811591 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461726-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DY9haBt0"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xpdXy5wNtz9s7p for ; Fri, 8 Sep 2017 23:32:34 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=Cdpx0E3jBSAMpQ9lLAXZtUMs03+xFZ7EEAVY3A8A0HYDg75q4X y1fkeN1u1q4x2kTgV7nIF7WNWnzub99qZHjusbJuGny+9GxSCdNpE4+dHF7tJn2r 0uKhSAgKmnuOKlbKd/NrQxHUPjGY8nxAxilJz2eYauVZQulOCjIckNPFc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=hgtnsgxA8p8ILixny3obCnxhKfw=; b=DY9haBt0bjX8ZHPkOau9 p0OHRD/HjLYHCA03U2i2ArJieCB4j8qF5GSb6+R95nbBslYh0hOBmgk86jW8k/6s UJevJ6x4BFNMCgF7z2IzkQ/1MehFTibWO4b0X1VLKevMyshImHMks9Wn5TZll3Rx +hkDgw2juK/hQPeinL95/zs= Received: (qmail 9301 invoked by alias); 8 Sep 2017 13:31:45 -0000 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 Received: (qmail 9199 invoked by uid 89); 8 Sep 2017 13:31:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2800, justin X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Sep 2017 13:31:43 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 305285628A; Fri, 8 Sep 2017 09:31:42 -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 Hdy0me3TO8bn; Fri, 8 Sep 2017 09:31:42 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 1FFDA56285; Fri, 8 Sep 2017 09:31:42 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 1EF974A4; Fri, 8 Sep 2017 09:31:42 -0400 (EDT) Date: Fri, 8 Sep 2017 09:31:42 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Justin Squirek Subject: [Ada] No room for new warning switches Message-ID: <20170908133142.GA87409@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch adds machinary to create new warning flags using the underscore "_" prefix. This is necessary because all letters of the alphabet and letters prefixed with a dot "." are used already. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Justin Squirek * switch-c.adb (Scan_Front_End_Switches): Add new warning switch case to handle underscore flags. * warnsw.adb, warnsw.ads (Set_Underscore_Warning_Switch): Create new procedure to handle underscores. Index: switch-c.adb =================================================================== --- switch-c.adb (revision 251892) +++ switch-c.adb (working copy) @@ -1268,8 +1268,20 @@ Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max)); end if; - -- Normal case, no dot + -- Case of underscore switch + elsif C = '_' and then Ptr < Max then + Ptr := Ptr + 1; + C := Switch_Chars (Ptr); + + if Set_Underscore_Warning_Switch (C) then + Store_Compilation_Switch ("-gnatw_" & C); + else + Bad_Switch ("-gnatw_" & Switch_Chars (Ptr .. Max)); + end if; + + -- Normal case, no dot + else if Set_Warning_Switch (C) then Store_Compilation_Switch ("-gnatw" & C); Index: warnsw.adb =================================================================== --- warnsw.adb (revision 251892) +++ warnsw.adb (working copy) @@ -471,6 +471,24 @@ return True; end Set_Dot_Warning_Switch; + ----------------------------------- + -- Set_Underscore_Warning_Switch -- + ----------------------------------- + + function Set_Underscore_Warning_Switch (C : Character) return Boolean is + begin + case C is + when others => + if Ignore_Unrecognized_VWY_Switches then + Write_Line ("unrecognized switch -gnatw_" & C & " ignored"); + else + return False; + end if; + end case; + + return True; + end Set_Underscore_Warning_Switch; + ---------------------------- -- Set_GNAT_Mode_Warnings -- ---------------------------- Index: warnsw.ads =================================================================== --- warnsw.ads (revision 251892) +++ warnsw.ads (working copy) @@ -147,6 +147,13 @@ -- the command line or .C in a string literal in pragma Warnings. Returns -- True for valid warning character C, False for invalid character. + function Set_Underscore_Warning_Switch (C : Character) return Boolean; + -- This function sets the warning switch or switches corresponding to the + -- given character preceded by an underscore. Used to process a -gnatw_ + -- switch on the command line or _C in a string literal in pragma Warnings. + -- Returns True for valid warnings character C, False for invalid + -- character. + procedure Set_GNAT_Mode_Warnings; -- This is called in -gnatg mode to set the warnings for gnat mode. It is -- also used to set the proper warning statuses for -gnatw.g. Note that