From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,89672537efe45443 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-27 00:28:16 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Source Analysis Tools for Ada95 Date: 27 Apr 2003 07:26:23 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: <7fc0d0f7.0304251607.efb4d7b@posting.google.com> <7fc0d0f7.0304261434.1f7f69fd@posting.google.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1051428494 22329 62.49.19.209 (27 Apr 2003 07:28:14 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sun, 27 Apr 2003 07:28:14 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: archiver1.google.com comp.lang.ada:36640 Date: 2003-04-27T07:26:23+01:00 List-Id: tony@probepak.com (Dr. Anthony Probe) writes: > > Gnat includes "gnatelim" which generates a list of gnat specific > > pragmas causing no object code to be built for dead code. You > > should be able to use this as a starting point for deleting unused > > code. > > Wouldn't a compiler only detect the obvious dead code (that which > isn't used from just analyzing the comp unit? I have never used gnatelim, because the one time I tried it took a long time (this was a few years ago) and I didn't really have a problem anyway. But its intention is to find and mark those subprograms (?and other constructs?) that aren't used in the closure. Sounds like what you're after! You need to get the binary distribution, because gnatelim isn't built as part of the compiler (I believe it's an ASIS application). Quotation from the 3.14p GNAT user's guide: When a program shares a set of Ada packages with other programs, it may happen that this program uses only a fraction of the subprograms defined in these packages. The code created for these unused subprograms increases the size of the executable. gnatelim tracks unused subprograms in an Ada program and outputs a list of GNAT-specific Eliminate pragmas (see next section) marking all the subprograms that are declared but never called. By placing the list of Eliminate pragmas in the GNAT configuration file `gnat.adc' and recompiling your program, you may decrease the size of its executable, because the compiler will not generate the code for 'eliminated' subprograms. The simplified syntax of the Eliminate pragma used by gnatelim is: pragma Eliminate (Library_Unit_Name, Subprogram_Name); where Library_Unit_Name full expanded Ada name of a library unit Subprogram_Name a simple or expanded name of a subprogram declared within this compilation unit Also, -gnatwu will warn of unused entities, including withed units. I think this is GNAT 3.15p or later. (we use -gnatwaL, switch on all warnings except elaboration ordering).