From patchwork Tue Apr 25 09:46:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 754670 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wByyp4c1Fz9s82 for ; Tue, 25 Apr 2017 19:46:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="XHvjZIYx"; dkim-atps=neutral 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=XnlR9Y0zgJdTpbEketDOdk/5vqFTwyfqQxXZXca/JabHUf/j+O Wxq3SPZFdDZwYDX6UGO1XKf+dss5P5l9hGCmYu/gmOhKMTJLIXXWggmxpKJoEbiF nPSrIv+k3r72f4sepkr76WDBXi50WktyenoohfraiBdQozh3Ovp4KCr8w= 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=lswzNAU7S+SKnHUqVpinMnV7Sq8=; b=XHvjZIYxgmgsmPwtGtOg PdaGBINGJPTiz6IioxJAbxaJYOOtpL0x+il8eb7aYMRIEI61UmC0kct+9WI7jpuW YVqPU24edCmyIQFeY2hJZcNnQVn4POMQPYGl7nfJh77fvhlh1HaGlxfsh4hoIYAx /ZmvfgVxdz5y9dHk9j1Fd/I= Received: (qmail 123847 invoked by alias); 25 Apr 2017 09:46:14 -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 123837 invoked by uid 89); 25 Apr 2017 09:46:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.1 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=heads, yyy, xxx 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; Tue, 25 Apr 2017 09:46:12 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D38373531; Tue, 25 Apr 2017 05:46:12 -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 h7HlZzTHxfzx; Tue, 25 Apr 2017 05:46:12 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id C1593350F; Tue, 25 Apr 2017 05:46:12 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id BD987521; Tue, 25 Apr 2017 05:46:12 -0400 (EDT) Date: Tue, 25 Apr 2017 05:46:12 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Wrong casing of restriction and check names Message-ID: <20170425094612.GA5882@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Fixes bugs in which the wrong casing was used for restriction names in pragmas Restrictions and Restriction_Warnings, and check names in pragma Check. No test is available -- too complicated to make it fail. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-04-25 Bob Duff * sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings): Use Source_Index (Current_Sem_Unit) to find the correct casing. * exp_prag.adb (Expand_Pragma_Check): Use Source_Index (Current_Sem_Unit) to find the correct casing. * par.adb (Par): Null out Current_Source_File, to ensure that the above bugs won't rear their ugly heads again. Index: exp_prag.adb =================================================================== --- exp_prag.adb (revision 247162) +++ exp_prag.adb (working copy) @@ -33,6 +33,7 @@ with Exp_Util; use Exp_Util; with Expander; use Expander; with Inline; use Inline; +with Lib; use Lib; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; @@ -432,11 +433,12 @@ Add_Str_To_Name_Buffer ("failed invariant from "); -- For all other checks, the string is "xxx failed at yyy" - -- where xxx is the check name with current source file casing. + -- where xxx is the check name with appropriate casing. else Get_Name_String (Nam); - Set_Casing (Identifier_Casing (Current_Source_File)); + Set_Casing + (Identifier_Casing (Source_Index (Current_Sem_Unit))); Add_Str_To_Name_Buffer (" failed at "); end if; Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 247165) +++ sem_prag.adb (working copy) @@ -9416,7 +9416,8 @@ if Is_Bad_Spelling_Of (Chars (Expr), Name_Enter) then Set_Casing - (Identifier_Casing (Current_Source_File)); + (Identifier_Casing + (Source_Index (Current_Sem_Unit))); Error_Msg_String (1 .. Rnm'Length) := Name_Buffer (1 .. Name_Len); Error_Msg_Strlen := Rnm'Length; Index: par.adb =================================================================== --- par.adb (revision 247150) +++ par.adb (working copy) @@ -1457,6 +1457,8 @@ procedure Labl is separate; procedure Load is separate; + Result : List_Id := Empty_List; + -- Start of processing for Par begin @@ -1472,13 +1474,13 @@ begin loop if Token = Tok_EOF then - Compiler_State := Analyzing; - return Pragmas; + Result := Pragmas; + exit; elsif Token /= Tok_Pragma then Error_Msg_SC ("only pragmas allowed in configuration file"); - Compiler_State := Analyzing; - return Error_List; + Result := Error_List; + exit; else P_Node := P_Pragma; @@ -1690,7 +1692,9 @@ Restore_Opt_Config_Switches (Save_Config_Switches); Set_Comes_From_Source_Default (False); - Compiler_State := Analyzing; - return Empty_List; end if; + + Compiler_State := Analyzing; + Current_Source_File := No_Source_File; + return Result; end Par;