Gabriel Dos Reis wrote:
On Thu, Aug 14, 2008 at 11:52 AM, Tom Tromey <[EMAIL PROTECTED]> wrote:
"Joseph" == Joseph S Myers <[EMAIL PROTECTED]> writes:

I'd like to see carets on by default as part of a major release -- say
GCC 5.0.  (First mention!!)

100% agreed.

-- Gaby

As I have mentioned before, we have always had very accurate caret
diagnostics (though we use | instead of ^ :-)) in GNAT, but decided
that brief error messages were the default. 97% of the time,
especially for experienced programmers, you really don't need
this information, and it is not worth the extra complexity in
the output. Furthermore, you certainly don't want this is you
are using an IDE which interprets the column numbers in the brief
messages and jumps you to the right location anyway (the great
majority of Ada users are using an IDE, not all, but certainly
most). That's not to say some of our users do not find the
caret diagnostics very valuable, and of course thats reasonable
as an option, but I wouldn't make it the default.

Now one significant difference between Ada and C in the gcc
arena is that the messages by default from GNAT always include
(highly accurate) column numbers, and that seems desirable
anyway, but assuming (I hope I assume right) that the intent
of caret diagnostics is to actually post flags in the columns,
I don't think that should be the default.

One argument in favor of making this the default is that this
is the only way to smoke out errors, but I think you could do
just as good a job of this by always displaying column numbers
and anyway using an IDE, including EMACS (I assume emacs can
handle columns fine), will notice problems and can be encouraged
to report problems once the messages get good enough to be
reasonable.

Another interesting capability in GNAT is the -gnatjnn flag which
causes a message and its continuation lines to be wrapped together
as a single message, and then broken into lines nn long:

Consider

     1. procedure q is
     2.    type u8 is range 1 .. 10;
     3.    a,b : u8 := 10;
     4. begin
     5.    a := b + 1;
     6. end;

default mode

q.adb:5:11: warning: value not in range of type "u8" defined at line 2
q.adb:5:11: warning: "Constraint_Error" will be raised at run time

in -gnatv mode:

     5.    a := b + 1;
                  |
        >>> warning: value not in range of type "u8" defined at line 2
        >>> warning: "Constraint_Error" will be raised at run time

in -gnatl mode:

     1. procedure q is
     2.    type u8 is range 1 .. 10;
     3.    a,b : u8 := 10;
     4. begin
     5.    a := b + 1;
                  |
        >>> warning: value not in range of type "u8" defined at line 2
        >>> warning: "Constraint_Error" will be raised at run time

     6. end;

default with -gnatj60

 q.adb:5:11: warning: value not in range of type "u8"
             defined at line 2, "Constraint_Error" will be
             raised at run time

-gnatv with -gnatj60

     5.    a := b + 1;
                  |
        >>> warning: value not in range of type "u8"
            defined at line 2, "Constraint_Error" will be
            raised at run time

-gnatl with -gnatj60

     1. procedure q is
     2.    type u8 is range 1 .. 10;
     3.    a,b : u8 := 10;
     4. begin
     5.    a := b + 1;
                  |
        >>> warning: value not in range of type "u8"
            defined at line 2, "Constraint_Error" will be
            raised at run time

     6. end;

Another possibility is -gnatjn999 which gathers a message
and all its continuation messages in one line, which
may be useful in an IDE context where you would like
the IDE to format the message (e.g. in a popup box)

The one thing that GNAT does not have is a notion of ranges
(in the above it would be a little clearer perhaps if the
range b+1 were flagged, but in fact given that we are
pointing to an overflow, pointing to the operator causing
it is worthwhile.










Reply via email to