From patchwork Thu Nov 20 11:24:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 412649 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 BE52C140142 for ; Thu, 20 Nov 2014 22:27:08 +1100 (AEDT) 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=DqTLaNuJ2wLqpkvaN69p5SNLO1eBGn/DHrDrHXspOm0S6aEeNT Pz/w2kZYFA+Lsd7ImdGQDrPaZRKDo7xNHwVgDcOKTkTkGo9lA0tSi15v7wECppi2 uTbOkZoQFEtrXFcdsuomPBh2k1DqlsGIpXjR0UMrtEijxNPCb578bST38= 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=SZ/mBLkS8z5kZ3Fiq+63AcEHlZY=; b=m34oleKxWmy9yNa5OWjO 4BlqYNeA+sf2cYiGoWbMzSf7zQhwJ18cXXE8tmKHMjxnyUzbfr2fPgGOqIeH8RKr qyn5D8zr9gU0lcZjiudVa0eaq8QosJQBl63DaK0Wqd5n2y9yLVNXFqlS8xNhMWHQ 5xNlWkhvrdAzHLqFztIM3QA= Received: (qmail 22424 invoked by alias); 20 Nov 2014 11:25:01 -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 22386 invoked by uid 89); 20 Nov 2014 11:25:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 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 (AES256-SHA encrypted) ESMTPS; Thu, 20 Nov 2014 11:24:59 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id F0128116B83; Thu, 20 Nov 2014 06:24:57 -0500 (EST) 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 g7N8VzVbzopC; Thu, 20 Nov 2014 06:24:57 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id DFB4D116A2B; Thu, 20 Nov 2014 06:24:57 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id D280191A7D; Thu, 20 Nov 2014 06:24:57 -0500 (EST) Date: Thu, 20 Nov 2014 06:24:57 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Give error message if duplicate Linker_Section given Message-ID: <20141120112457.GA11773@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Like other similar pragmas, we should disallow duplicate pragma or aspect Linker_Section for non-overloadable entities (for the case of overloading, the pragma only applies to previous entities which do not have such a pragma). The following should compile with the given error: 1. package Pkg1 is 2. Var_Dyn : natural; 3. pragma Linker_Section (Var_Dyn, ".data_dyn"); 4. pragma Linker_Section (Var_Dyn, ".data_dyn1"); | >>> Linker_Section already specified for "Var_Dyn" at line 3 5. end Pkg1; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-11-20 Robert Dewar * sem_prag.adb (Analyze_Pragma, case Linker_Section): Detect duplicate Linker_Section. Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 217838) +++ sem_prag.adb (working copy) @@ -16380,6 +16380,7 @@ when Pragma_Linker_Section => Linker_Section : declare Arg : Node_Id; Ent : Entity_Id; + LPE : Node_Id; begin GNAT_Pragma; @@ -16398,9 +16399,18 @@ case Ekind (Ent) is -- Objects (constants and variables) and types. For these cases - -- all we need to do is to set the Linker_Section_pragma field. + -- all we need to do is to set the Linker_Section_pragma field, + -- checking that we do not have a duplicate. when E_Constant | E_Variable | Type_Kind => + LPE := Linker_Section_Pragma (Ent); + + if Present (LPE) then + Error_Msg_Sloc := Sloc (LPE); + Error_Msg_NE + ("Linker_Section already specified for &#", Arg1, Ent); + end if; + Set_Linker_Section_Pragma (Ent, N); -- Subprograms