From patchwork Mon Oct 14 13:10:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 283213 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4729D2C0356 for ; Tue, 15 Oct 2013 00:10:38 +1100 (EST) 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=YKZlzlqyTin+C5Mc3pH1WFkEKEo+xs2yJp1iq8eFJIn4+OOl+l pGDS5p7yTfjGREiszBsCMvRVl9KsHuxHYuXYPc0MTU6OoxJu5H/QV+IkQEkF5b3V fOFCshNyVK2IEjCJP3ma1+F0gH3HzDP5Q6IS+V27b/CmG/TuBxl/1CUJA= 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=YNnab8zWvTLyasFe/y+BtHSYMrM=; b=SC0l+fi8drrfZIkmN2vH BUf92HNgaXhRqTHTKlVoPMLTZel+pPz673LK3EpNMaR6eLgdDr0/3dCAHuSOljGh 4VT/WJ8TY1I2tbk1qMO8U9/JAjXeelZkMlILo8zjSDC2/BTf3VeQ9TIhcw8W7wwi F1Ktr4z/Bgl1AGPK+j+bSeo= Received: (qmail 7275 invoked by alias); 14 Oct 2013 13:10:31 -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 7265 invoked by uid 89); 14 Oct 2013 13:10:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=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; Mon, 14 Oct 2013 13:10:30 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id BD12B116259; Mon, 14 Oct 2013 09:10:50 -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 JqezHL7RJJvd; Mon, 14 Oct 2013 09:10:50 -0400 (EDT) Received: from kwai.gnat.com (unknown [IPv6:2620:20:4000:0:a6ba:dbff:fe26:1f63]) by rock.gnat.com (Postfix) with ESMTP id AA1411160F2; Mon, 14 Oct 2013 09:10:50 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 4C7253FB31; Mon, 14 Oct 2013 09:10:28 -0400 (EDT) Date: Mon, 14 Oct 2013 09:10:28 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Overlapping parameter is error not warning in Ada 2012 mode Message-ID: <20131014131028.GA30055@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) This patch implements the required incompatible change in Ada 2012 that makes overlap of elementary parameters passed as OUT or IN OUT an error (rather than a warning situation). It also implements the debug flag -gnatd.E that converts this back to a warning. The following program compiled in Ada 2012 mode gives: 1. with Text_IO; use Text_IO; 2. procedure OverlapWarn is 3. procedure OW (a, b : out Integer) is 4. begin 5. A := 3; 6. B := 3; 7. end; 8. X : Integer; 9. begin 10. OW (X, X); | >>> writable actual for "a" overlaps with actual for "b" 11. Put_Line (X'Img); 12. end OverlapWarn; But if -gnatd.E is given in Ada 2012 mode, the error is a warning: 1. with Text_IO; use Text_IO; 2. procedure OverlapWarn is 3. procedure OW (a, b : out Integer) is 4. begin 5. A := 3; 6. B := 3; 7. end; 8. X : Integer; 9. begin 10. OW (X, X); | >>> warning: writable actual for "a" overlaps with actual for "b" 11. Put_Line (X'Img); 12. end OverlapWarn; And the program can be executed, and outputs 3 Tested on x86_64-pc-linux-gnu, committed on trunk 2013-10-14 Robert Dewar * debug.adb: Document -gnatd.E. * gnat1drv.adb (Adjust_Global_Switches): Set Error_To_Warning if -gnatd.E set. * opt.ads (Error_To_Warning): New switch. * osint.adb: Minor reformatting. * sem_warn.adb (Warn_On_Overlapping_Actuals): Overlap is error in some cases in Ada 2012 mode (unless Error_To_Warning) is set. * sem_warn.ads (Warn_On_Overlapping_Actuals): Document error in Ada 2012 mode. Index: debug.adb =================================================================== --- debug.adb (revision 203524) +++ debug.adb (working copy) @@ -122,7 +122,7 @@ -- d.B -- d.C Generate concatenation call, do not generate inline code -- d.D SPARK strict mode - -- d.E + -- d.E Turn selected errors into warnings -- d.F SPARK mode -- d.G Frame condition mode for gnat2why -- d.H @@ -581,22 +581,26 @@ -- d.w This flag turns off the scanning of loops to detect possible -- infinite loops. + -- d.x No exception handlers in generated code. This causes exception + -- handlers to be eliminated from the generated code. They are still + -- fully compiled and analyzed, they just get eliminated from the + -- code generation step. + -- d.A There seems to be a problem with ASIS if we activate the circuit -- for reading and writing the aspect specification hash table, so -- for now, this is controlled by the debug flag d.A. The hash table -- is only written and read if this flag is set. - -- d.x No exception handlers in generated code. This causes exception - -- handlers to be eliminated from the generated code. They are still - -- fully compiled and analyzed, they just get eliminated from the - -- code generation step. - -- d.C Generate call to System.Concat_n.Str_Concat_n routines in cases -- where we would normally generate inline concatenation code. -- d.D SPARK strict mode. Interpret compiler permissions as strictly as -- possible in SPARK mode. - -- + + -- d.E Turn selected errors into warnings. This debug switch causes a + -- specific set of error messages into warnings. Setting this switch + -- causes Opt.Error_To_Warning to be set to True. + -- d.F SPARK mode. Generate AST in a form suitable for formal -- verification, as well as additional cross reference information in -- ALI files to compute effects of subprograms. Note that ALI files Index: gnat1drv.adb =================================================================== --- gnat1drv.adb (revision 203521) +++ gnat1drv.adb (working copy) @@ -117,6 +117,13 @@ Relaxed_RM_Semantics := True; end if; + -- -gnatd.E sets Error_To_Warning mode, causing selected error messages + -- to be treated as warnings instead of errors. + + if Debug_Flag_Dot_EE then + Error_To_Warning := True; + end if; + -- Disable CodePeer_Mode in Check_Syntax, since we need front-end -- expansion. Index: sem_warn.adb =================================================================== --- sem_warn.adb (revision 203521) +++ sem_warn.adb (working copy) @@ -3410,13 +3410,27 @@ then null; - -- Here we may need to issue message + -- Here we may need to issue overlap message else Error_Msg_Warn := + + -- Overlap checking is an error only in Ada 2012. For + -- earlier versions of Ada, this is a warning. + Ada_Version < Ada_2012 - or else not Is_Elementary_Type (Etype (Form1)); + -- Overlap is only illegal in Ada 2012 in the case of + -- elementary types (passed by copy). For other types, + -- we always have a warning in all Ada versions. + + or else not Is_Elementary_Type (Etype (Form1)) + + -- Finally, debug flag -gnatd.E changes the error to a + -- warning even in Ada 2012 mode. + + or else Error_To_Warning; + declare Act : Node_Id; Form : Entity_Id; @@ -3457,23 +3471,28 @@ then if Act1 = First_Actual (N) then Error_Msg_FE - ("`IN OUT` prefix overlaps with " - & "actual for&?I?", Act1, Form); + ("<`IN OUT` prefix overlaps with " + & "actual for&", Act1, Form); else -- For greater clarity, give name of formal Error_Msg_Node_2 := Form; Error_Msg_FE - ("writable actual for & overlaps with " - & "actual for&?I?", Act1, Form); + ("