comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Eachus <rieachus@comcast.net>
Subject: Re: Wrong GNAT warning. How to suppress it?
Date: Sun, 26 Nov 2017 11:31:40 -0800 (PST)
Date: 2017-11-26T11:31:40-08:00	[thread overview]
Message-ID: <5e77d738-29d1-46db-aad1-24560acda13f@googlegroups.com> (raw)
In-Reply-To: <ovcb98$1a93$1@gioia.aioe.org>

On Saturday, November 25, 2017 at 1:03:24 PM UTC-5, Victor Porton wrote:
> How to eliminate the GNAT warning in the below program?

For the record, pragma No_Return is deprecated (J.15.2) in favor of aspect No_Return:
  procedure Fatal_Error(M: Message);
    with No_Return;

That allows the compiler to optimize the calling side, for example by not saving register values.

But keep in mind that when GNAT warns you about a function with a path that does not lead to a return statement or raise statement, it is warning about an error that can occur at run-time.  Yes, you will get Program_Error raised, but sometimes that will unexpectedly be handled by a when others handler.

What I do is have a package:

package To_Be_Done is
  procedure TBD(Which: Integer := 0);
    with No_Return;
  function TBD(Which: Integer := 0) return Integer;
  -- and a few other cases
end To_Be_Done;

One advantage of this is that you never check in To_Be_Done for the release (not debug) version.  Can you 'ship' with TBDs?  Of course, but if you intend to do that, you want a version of the To_Be_Done package which is customer friendly, and doesn't splat debug info all over the screen.

The value Which if passed is expected to be the number in the bug list for this particular case.  I'd like to use aspect No_Return for the functions, but, for whatever reason it is limited to procedures and generic procedures.


      parent reply	other threads:[~2017-11-26 19:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-25 18:03 Wrong GNAT warning. How to suppress it? Victor Porton
2017-11-25 18:09 ` Pascal Obry
2017-11-25 18:27 ` Victor Porton
2017-11-25 19:03   ` Pascal Obry
2017-11-26 19:31 ` Robert Eachus [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox