comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <see.reply.to@maps.futureapps.de>
Subject: not X'Length
Date: Thu, 15 May 2008 11:19:43 +0200
Date: 2008-05-15T11:19:44+02:00	[thread overview]
Message-ID: <482c0030$0$7542$9b4e6d93@newsspool1.arcor-online.net> (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;



             reply	other threads:[~2008-05-15  9:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15  9:19 Georg Bauhaus [this message]
2008-05-15  9:39 ` not X'Length 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
replies disabled

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