From patchwork Thu Mar 15 09:16:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 146865 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 B0CA5B6F98 for ; Thu, 15 Mar 2012 20:16:31 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1332407794; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=O5pnyAo37z5Y/yvbGIQB MZ93yU0=; b=O0kV8wzX3RelXin+M3Li9LcVXu4jxz76SnkIyr4uoAt1uCFAeEy6 WPTqRUI2ho45j22AJujpXJ9kYZfMB64bRen2RUbffnaBC+3YA9zRVo/YJXw9Wg4W haPVBSQX0fXsKYGqQOC24jhVBz682/1bh7KXFHjkCQ7KB3kXUW3hzgI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=qr0wELaLic8IVnTNcStL+ZmFv/paX9bjNi+oQwxiP75clxyK+ae4JMPE0iBH41 c/j/QuqmCIOs3xn4XJjc/GtVwkURLWSoyucOr171qbaOFGW8mnkenFgADcJkbbXV JhblQjRlBS9FUMZBsae04hRrIiGrgtRGHQEQmJT7pwZVQ=; Received: (qmail 23839 invoked by alias); 15 Mar 2012 09:16:21 -0000 Received: (qmail 23808 invoked by uid 22791); 15 Mar 2012 09:16:18 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 15 Mar 2012 09:16:04 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 14BAC1C6C1B; Thu, 15 Mar 2012 05:16:04 -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 kO2k0SwtZNEk; Thu, 15 Mar 2012 05:16:04 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id ED0131C6C1A; Thu, 15 Mar 2012 05:16:03 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id E878192BF6; Thu, 15 Mar 2012 05:16:03 -0400 (EDT) Date: Thu, 15 Mar 2012 05:16:03 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Switch to control maximum number of instantiations Message-ID: <20120315091603.GA3589@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 patch adds the switch (-gnateinn, MAX_INSTANTIATIONS=nn in VMS) to control the maximum number of instantiations. This may be used to increase the limit from the default of 8000 in the very rare case where a single unit legitimately has more than 8000 instantiations. The following program: 1. procedure MaxInst is 2. generic package P is 3. X : Integer; 4. end; 5. 6. package P1 is new P; 7. package P2 is new P; 8. package P4 is new P; 9. package P5 is new P; 10. package P6 is new P; 11. package P7 is new P; 12. package P8 is new P; 13. package P9 is new P; 14. begin 15. null; 16. end; If compiled with -gnatei4 -gnatj64, yields maxinst.adb:12:04: too many instantiations, exceeds max of 4, limit can be changed using -gnateinn switch compilation abandoned Tested on x86_64-pc-linux-gnu, committed on trunk 2012-03-15 Robert Dewar * errout.ads: Add entry for translating -gnateinn to /MAX_INSTANTIATIONS for VMS. * hostparm.ads (Max_Instantiations): Moved to Opt. * opt.ads (Maximum_Instantiations): Moved from Hostparm, and renamed. * sem_ch12.adb (Maximum_Instantiations): New name of Max_Instantiations (Analyze_Package_Instantiation): Change error msg for too many instantiations (mention -gnateinn switch). * switch-c.adb (Scan_Front_End_Switches): Implement -gnateinn switch. * switch.ads: Minor comment update. * usage.adb (Usage): Output line for -maxeinn switch. * vms_data.ads: Add entry for MAX_INSTANTIATIONS (-gnateinn). Index: switch-c.adb =================================================================== --- switch-c.adb (revision 185390) +++ switch-c.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -482,6 +482,13 @@ Generate_Processed_File := True; Ptr := Ptr + 1; + -- -gnatei (max number of instantiations) + + when 'i' => + Ptr := Ptr + 1; + Scan_Pos + (Switch_Chars, Max, Ptr, Maximum_Instantiations, C); + -- -gnateI (index of unit in multi-unit source) when 'I' => Index: usage.adb =================================================================== --- usage.adb (revision 185390) +++ usage.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -197,6 +197,11 @@ Write_Switch_Char ("eG"); Write_Line ("Generate preprocessed source"); + -- Line for -gnatei switch + + Write_Switch_Char ("einn"); + Write_Line ("Set maximumum number of instantiations to nn"); + -- Line for -gnateI switch Write_Switch_Char ("eInn"); Index: sem_ch12.adb =================================================================== --- sem_ch12.adb (revision 185417) +++ sem_ch12.adb (working copy) @@ -34,7 +34,6 @@ with Fname; use Fname; with Fname.UF; use Fname.UF; with Freeze; use Freeze; -with Hostparm; with Itypes; use Itypes; with Lib; use Lib; with Lib.Load; use Lib.Load; @@ -3784,8 +3783,10 @@ -- Here is a defence against a ludicrous number of instantiations -- caused by a circular set of instantiation attempts. - if Pending_Instantiations.Last > Hostparm.Max_Instantiations then - Error_Msg_N ("too many instantiations", N); + if Pending_Instantiations.Last > Maximum_Instantiations then + Error_Msg_Uint_1 := UI_From_Int (Maximum_Instantiations); + Error_Msg_N ("too many instantiations, exceeds max of^", N); + Error_Msg_N ("\limit can be changed using -gnateinn switch", N); raise Unrecoverable_Error; end if; Index: errout.ads =================================================================== --- errout.ads (revision 185390) +++ errout.ads (working copy) @@ -380,6 +380,9 @@ Gname8 : aliased constant String := "gnat2012"; Vname8 : aliased constant String := "2012"; + Gname9 : aliased constant String := "gnateinn"; + Vname9 : aliased constant String := "MAX_INSTANTIATIONS=nn"; + type Cstring_Ptr is access constant String; Gnames : array (Nat range <>) of Cstring_Ptr := @@ -390,7 +393,8 @@ Gname5'Access, Gname6'Access, Gname7'Access, - Gname8'Access); + Gname8'Access, + Gname9'Access); Vnames : array (Nat range <>) of Cstring_Ptr := (Vname1'Access, @@ -400,7 +404,8 @@ Vname5'Access, Vname6'Access, Vname7'Access, - Vname8'Access); + Vname8'Access, + Vname9'Access); ----------------------------------------------------- -- Global Values Used for Error Message Insertions -- Index: vms_data.ads =================================================================== --- vms_data.ads (revision 185390) +++ vms_data.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1996-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1996-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1926,11 +1926,14 @@ -- When using a project file, GNAT MAKE creates a temporary mapping file -- and communicates it to the compiler using this switch. - S_GCC_Multi : aliased constant S := "/MULTI_UNIT_INDEX=#" & - "-gnateI#"; - -- /MULTI_UNIT_INDEX=nnn + S_GCC_MaxI : aliased constant S := "/MAX_INSTANTIATIONS=#" & + "-gnatei#"; + + -- /MAX_INSTANTIATIONS=nnn -- - -- Specify the index of the unit to compile in a multi-unit source file. + -- Specify the maximum number of instantiations permitted. The default + -- value is 8000, which is probably enough for all programs except those + -- containing some kind of runaway unintended instantiation loop. S_GCC_Mess : aliased constant S := "/MESSAGES_PROJECT_FILE=" & "DEFAULT " & @@ -1951,6 +1954,12 @@ -- HIGH A great number of messages are output, most of them not -- being useful for the user. + S_GCC_Multi : aliased constant S := "/MULTI_UNIT_INDEX=#" & + "-gnateI#"; + -- /MULTI_UNIT_INDEX=nnn + -- + -- Specify the index of the unit to compile in a multi-unit source file. + S_GCC_Nesting : aliased constant S := "/MAX_NESTING=#" & "-gnatyL#"; -- /MAX_NESTING=nnn @@ -3585,6 +3594,7 @@ S_GCC_Output 'Access, S_GCC_Machine 'Access, S_GCC_Mapping 'Access, + S_GCC_MaxI 'Access, S_GCC_Multi 'Access, S_GCC_Mess 'Access, S_GCC_Nesting 'Access, Index: opt.ads =================================================================== --- opt.ads (revision 185390) +++ opt.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -931,6 +931,12 @@ -- extension, as set by the appropriate switch. If no switch is given, -- then this value is initialized by Osint to the appropriate value. + Maximum_Instantiations : Int := 8000; + -- GNAT + -- Maximum number of instantiations permitted (to stop runaway cases + -- of nested instantiations). These situations probably only occur in + -- specially concocted test cases. Can be modified by -gnateinn switch. + Maximum_Processes : Positive := 1; -- GNATMAKE, GPRMAKE, GPRBUILD -- Maximum number of processes that should be spawned to carry out @@ -940,12 +946,6 @@ -- GNATMAKE -- Set to True if minimal recompilation mode requested - Special_Exception_Package_Used : Boolean := False; - -- GNAT - -- Set to True if either of the unit GNAT.Most_Recent_Exception or - -- GNAT.Exception_Traces is with'ed. Used to inhibit transformation of - -- local raise statements into gotos in the presence of either package. - Multiple_Unit_Index : Int; -- GNAT -- This is set non-zero if the current unit is being compiled in multiple @@ -1182,6 +1182,12 @@ -- GNAT -- Set True if a pragma Short_Descriptors applies to the current unit. + Special_Exception_Package_Used : Boolean := False; + -- GNAT + -- Set to True if either of the unit GNAT.Most_Recent_Exception or + -- GNAT.Exception_Traces is with'ed. Used to inhibit transformation of + -- local raise statements into gotos in the presence of either package. + Sprint_Line_Limit : Nat := 72; -- GNAT -- Limit values for chopping long lines in Sprint output, can be reset Index: hostparm.ads =================================================================== --- hostparm.ads (revision 185390) +++ hostparm.ads (working copy) @@ -69,11 +69,6 @@ -- of file names in the library, must be at least Max_Line_Length, but -- can be larger. - Max_Instantiations : constant := 8000; - -- Maximum number of instantiations permitted (to stop runaway cases - -- of nested instantiations). These situations probably only occur in - -- specially concocted test cases. - Tag_Errors : constant Boolean := False; -- If set to true, then brief form error messages will be prefaced by -- the string "error:". Used as default for Opt.Unique_Error_Tag. Index: switch.ads =================================================================== --- switch.ads (revision 185390) +++ switch.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -123,9 +123,8 @@ Ptr : in out Integer; Result : out Pos; Switch : Character); - -- Scan positive integer parameter for switch. On entry, Ptr points just - -- past the switch character, on exit it points past the last digit of the - -- integer value. + -- Scan positive integer parameter for switch. Identical to Scan_Nat with + -- same parameters except that zero is considered out of range. procedure Bad_Switch (Switch : Character); procedure Bad_Switch (Switch : String);