Re: Ada checks suppression thanks to compilation options and Ada conformity



Dennis Lee Bieber <wlfraed@xxxxxxxxxxxxx> writes:
[...]
Well... from my lowly perspective...

1) One text book describes "pragma" as a "directive to the
compiler"... Compilation options can also be considered "directives to
the compiler"

Sure, but pragmas are defined by the language; compilation options are
not.

2) Many of my Ada texts tend to treat "pragma" as a "suggestion" for
the compiler -- and indicate that compilers are allowed to ignore
pragmas for which they are not coded

Implementations are allowed to define their own pragmas. If a
compiler doesn't recognize the name of a pragma, it must issue a
warning, and the pragma has no effect.

But this doens't apply to pragma Suppress, which is defined by the
language; for that, you have to look at what the standard specifically
says about pragma Suppress. A pragma Suppress gives the compiler
permission to omit the specified check(s). It doesn't require it to
do so, and a conforming compiler could ignore pragma Suppress
altogether.

The purpose is not to allow operations that would raise exceptions;
it's to allow faster code to be generated, based on the assumption
that the exceptions would not have been raised. In other words, using
pragma Suppress means that the burden of avoiding overflows and other
errors is on the programmer rather than on the compiler.

3) The absence of a "pragma X" does not imply "pragma NOT-X" (eg,
absence of "pragma Suppress" does not imply "pragma Suppress NONE"

Yes, it does. The language standard requires certain checks to be
performed. This requirement applies *unless* pragma Suppress is used.
If you don't use pragma Suppress (or some implementation-defined
pragma with similar semantics) and a required check is not performed,
then the implementation is failing to conform to the standard.

This isn't necessarily a bad thing. If a compiler provides a
command-line option to suppress all checks, that can be quite useful;
it's easier than modifying the source every time you want to disable
or enable checks. But a compiler with such an option specified is not
a standard-conforming Ada compiler.

There is a counter-argument to this. The input to the compiler is one
or more compilation units; the standard doesn't specify how a
compilation unit is represented. It could be argued that, if you
specify a compiler command-line option to suppress all checks, it
causes the compilation unit to consist of the specified source file
*plus* a "pragma Suppress(All_Checks);" at the top.

Conclusion: Always read the documentation for the compiler in use.

Absolutely.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: request for feedback: making foreign function calls to C printf-style functions safer
    ... - compiler would report that. ... syntax for such a feature, but we are talking about an optional pragma, ... fine even after the format specifier syntax had been extended. ... compiler should check for in the format string. ...
    (comp.lang.modula2)
  • Re: include file question
    ... Where did you read that #pragma once is obsolete? ... because it suggests that what you need is some kind of weird compiler hack to make your ... inside the header file to prevent multiple execution of the contents. ... documentation about Objective C, which is a language which is NOT the C++ language, has ...
    (microsoft.public.vc.mfc)
  • Re: include file question
    ... First off I first read that you could keep the compiler ... But then I read that #pragma once is obsolete? ... The #include guards are portable since the beginning of time, ... Note that some headers use neither because they are ...
    (microsoft.public.vc.mfc)
  • Re: Packages private parts and protected types
    ... unneeded bodies which Ada95 solved with a pragma. ... a source file containing that body. ... accidental error to result in the compiler accepting a package without ...
    (comp.lang.ada)
  • Re: GNAT subunit naming
    ... parameter to the Source_File_Name pragma. ... Subunit_File_Name parameter, the compiler rejects it. ... What I would like to be able to do is to specify each subunit ...
    (comp.lang.ada)