comp.lang.ada
 help / color / mirror / Atom feed
* not X'Length
@ 2008-05-15  9:19 Georg Bauhaus
  2008-05-15  9:39 ` christoph.grein
  0 siblings, 1 reply; 8+ messages in thread
From: Georg Bauhaus @ 2008-05-15  9:19 UTC (permalink / raw)


What do you think of the error messages referring to line 9?
Does it make sense for a a programmer to expect that a compiler
can/should become especially upset when it sees (or maybe,
does not see) "not <universal_integer>"?

Parentheses and "not in" were left out deliberately.

procedure B is
   X: array(1 .. 10) of Boolean;
   type Gotcha is mod 2**8;
begin
   if X'Length in Positive then
      null;
   end if;

   if not X'Length in Positive then
      null;
   end if;

   if not X'Length in Gotcha then
      null;
   end if;

   if not Natural'(X'Length) in Positive then
      null;
   end if;
end B;

Copyright 1992-2005 Free Software Foundation, Inc.

Compiling: b.adb (source file time stamp: 2008-05-15 08:51:18)

     1. procedure B is
     2.    X: array(1 .. 10) of Boolean;
     3.    type Gotcha is mod 2**8;
     4. begin
     5.    if X'Length in Positive then
                       |
        >>> warning: condition is always True

     6.       null;
     7.    end if;
     8.
     9.    if not X'Length in Positive then
                           |
        >>> incompatible types

    10.       null;
    11.    end if;
    12.
    13.    if not X'Length in Gotcha then
              1            2
        >>> warning: not expression should be parenthesized here
        >>> warning: condition is always True

    14.       null;
    15.    end if;
    16.
    17.    if not Natural'(X'Length) in Positive then
              |
        >>> operator "Not" not defined for type "Standard.Natural"

    18.       null;
    19.    end if;
    20. end B;

 20 lines: 2 errors, 3 warnings
gnatmake: "b.adb" compilation error


---8<---8<---8<---

    Copyright (c) 1994-2006, SofCheck, Inc.  All Rights Reserved.
Compiling 'b.adb': Thu May 15 10:59:19 2008

Source file: b.adb   Thu May 15 11:08:34 2008

    1 procedure B is
    2    X: array(1 .. 10) of Boolean;
    3    type Gotcha is mod 2**8;
    4 begin
    5    if X'Length in Positive then
    6       null;
    7    end if;
    8
    9    if not X'Length in Positive then
                         *
*****Error: LRM:8.6(28) Inappropriate operands for "IN" operation,
continuing
   10       null;
   11    end if;
   12
   13    if not X'Length in Gotcha then
   14       null;
   15    end if;
   16
   17    if not Natural'(X'Length) in Positive then
            *
*****Error: LRM:8.4(1) Unary operator "NOT" on Integer not directly visible,
*****        use clause or conversion might be needed
   18       null;
   19    end if;
   20 end B;



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-05-16 12:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-15  9:19 not X'Length Georg Bauhaus
2008-05-15  9:39 ` christoph.grein
2008-05-15 10:12   ` christoph.grein
2008-05-15 20:48   ` Georg Bauhaus
2008-05-15 22:20     ` Adam Beneschan
2008-05-16  8:04       ` Manuel Collado
2008-05-16  8:15       ` Georg Bauhaus
2008-05-16 12:52     ` Stephen Leake

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