public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Really crummy error messages, was Re: Ada files now checked in
@ 2001-10-07 14:34 Phil Edwards
  2001-10-07 23:01 ` Really crummy error messages Florian Weimer
  2001-10-08 11:09 ` Really crummy error messages, was Re: Ada files now checked in Zack Weinberg
  0 siblings, 2 replies; 9+ messages in thread
From: Phil Edwards @ 2001-10-07 14:34 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: dewar, fw, bosch, dnovillo, gcc, kenner, zack

On Sun, Oct 07, 2001 at 04:19:16PM +0200, Gabriel Dos Reis wrote:
> dewar@gnat.com writes:
> 
> | j.adb:3:04: "xyz" is undefined
> | 
> | compared to the c message
> | 
> | j.c:1: `asdf' undeclared (first use this function)
> 
> For a non-native English speaker like me, I have always questioned
> myself why the latter choice (which I find odd and difficult to read)
> is current practice and not the former.  FWIW, I would suggest that we
> switch to Robert's suggestion.

Even native English speakers, like me, get confused, and here's why:

For "first use this function" to be a correct English sentence [fragment],
there is only one possible parse, and it's not what is intended.  "First use
this function" is an /imperative/ with "use" as a verb (pronounced with a 'z'
sound), and always leaves new users wondering, "first use /which/ function?"

But GCC wants "use" to be a noun, pronounced with an 's' sound.  What we
really want to say is any of:

    j.c:1: `asdf' undeclared (first use in this function)
    j.c:1: `asdf' undeclared (first time used in this function)
    j.c:1: `asdf' undeclared (first occurrence in this function)

(Although maybe "is undeclared" would be better for C than "is undefined.")

Please, let's fix this.


Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams

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

* Re: Really crummy error messages
  2001-10-07 14:34 Really crummy error messages, was Re: Ada files now checked in Phil Edwards
@ 2001-10-07 23:01 ` Florian Weimer
  2001-10-08 11:09 ` Really crummy error messages, was Re: Ada files now checked in Zack Weinberg
  1 sibling, 0 replies; 9+ messages in thread
From: Florian Weimer @ 2001-10-07 23:01 UTC (permalink / raw)
  To: Phil Edwards; +Cc: gcc

Phil Edwards <pedwards@disaster.jaj.com> writes:

> For "first use this function" to be a correct English sentence [fragment],
> there is only one possible parse, and it's not what is intended.  "First use
> this function" is an /imperative/ with "use" as a verb (pronounced with a 'z'
> sound), and always leaves new users wondering, "first use /which/ function?"

I think this error message is dating back to the old K&R
prototype-less days, when you declared functions implicitly by
calling ("using") them.  After a call such as "foo()", you can take
the address of the function by just writing "foo" (without further
declarations).

At least that's my guess.  In any case, the error message is really
misleading, close to "tagged type must be declared at library
level". ;-)

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

* Re: Really crummy error messages, was Re: Ada files now checked in
  2001-10-07 14:34 Really crummy error messages, was Re: Ada files now checked in Phil Edwards
  2001-10-07 23:01 ` Really crummy error messages Florian Weimer
@ 2001-10-08 11:09 ` Zack Weinberg
  2001-10-08 13:31   ` Phil Edwards
  1 sibling, 1 reply; 9+ messages in thread
From: Zack Weinberg @ 2001-10-08 11:09 UTC (permalink / raw)
  To: Phil Edwards; +Cc: Gabriel Dos Reis, dewar, fw, bosch, dnovillo, gcc, kenner

On Sun, Oct 07, 2001 at 05:35:47PM -0400, Phil Edwards wrote:
> 
>     j.c:1: `asdf' undeclared (first use in this function)
>     j.c:1: `asdf' undeclared (first time used in this function)
>     j.c:1: `asdf' undeclared (first occurrence in this function)
> 
> (Although maybe "is undeclared" would be better for C than "is undefined.")
> 
> Please, let's fix this.

Hmm...

$ cat >test.c
int foo() { baz; }
$ gcc test.c
test.c: In function `foo':
test.c:1: `baz' undeclared (first use in this function)
test.c:1: (Each undeclared identifier is reported only once
test.c:1: for each function it appears in.)
$

Where is this "first use this function" coming from?

While we're bitching, I am sick of seeing

test.c:1: (Each undeclared identifier is reported only once
test.c:1: for each function it appears in.)

I think the error message is perfectly clear without that.

zw

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

* Re: Really crummy error messages, was Re: Ada files now checked in
  2001-10-08 11:09 ` Really crummy error messages, was Re: Ada files now checked in Zack Weinberg
@ 2001-10-08 13:31   ` Phil Edwards
  2001-10-08 16:49     ` Tim Hollebeek
  2001-10-11 14:04     ` Zack Weinberg
  0 siblings, 2 replies; 9+ messages in thread
From: Phil Edwards @ 2001-10-08 13:31 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: Gabriel Dos Reis, dewar, fw, bosch, dnovillo, gcc, kenner

On Mon, Oct 08, 2001 at 11:09:03AM -0700, Zack Weinberg wrote:
> $ cat >test.c
> int foo() { baz; }
> $ gcc test.c
> test.c: In function `foo':
> test.c:1: `baz' undeclared (first use in this function)
> test.c:1: (Each undeclared identifier is reported only once
> test.c:1: for each function it appears in.)
> $
> 
> Where is this "first use this function" coming from?

cp/lex.c, around line 1290.


> While we're bitching, I am sick of seeing
> 
> test.c:1: (Each undeclared identifier is reported only once
> test.c:1: for each function it appears in.)
> 
> I think the error message is perfectly clear without that.

I'd agree with this too.  Maybe GCC should have a beginner's mode?  :-)

Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams

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

* Re: Really crummy error messages, was Re: Ada files now checked in
  2001-10-08 13:31   ` Phil Edwards
@ 2001-10-08 16:49     ` Tim Hollebeek
  2001-10-09 23:32       ` Fergus Henderson
  2001-10-11 14:04     ` Zack Weinberg
  1 sibling, 1 reply; 9+ messages in thread
From: Tim Hollebeek @ 2001-10-08 16:49 UTC (permalink / raw)
  To: Phil Edwards
  Cc: Zack Weinberg, Gabriel Dos Reis, dewar, fw, bosch, dnovillo, gcc, kenner

On Mon, Oct 08, 2001 at 04:32:25PM -0400, Phil Edwards wrote:
> 
> > While we're bitching, I am sick of seeing
> > 
> > test.c:1: (Each undeclared identifier is reported only once
> > test.c:1: for each function it appears in.)
> > 
> > I think the error message is perfectly clear without that.
> 
> I'd agree with this too.  Maybe GCC should have a beginner's mode?  :-)

how about --verbose-errors, and have both a one-line and paragraph
explanation of each error?

  test.c:1: Message always goes here
  test.c:1: (iff --verbose errors, extended explanation
  test.c:1:  more...
  test.c:1:  etc)

This way you can normally use the normal options, and stick in
--verbose-errors when you see a new message or one you don't
understand.

-Tim

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

* Re: Really crummy error messages, was Re: Ada files now checked in
  2001-10-08 16:49     ` Tim Hollebeek
@ 2001-10-09 23:32       ` Fergus Henderson
  2001-10-10  2:25         ` Florian Weimer
  2001-10-10 11:00         ` Phil Edwards
  0 siblings, 2 replies; 9+ messages in thread
From: Fergus Henderson @ 2001-10-09 23:32 UTC (permalink / raw)
  To: Tim Hollebeek; +Cc: gcc

On 08-Oct-2001, Tim Hollebeek <tim@hollebeek.com> wrote:
> On Mon, Oct 08, 2001 at 04:32:25PM -0400, Phil Edwards wrote:
> > 
> > > While we're bitching, I am sick of seeing
> > > 
> > > test.c:1: (Each undeclared identifier is reported only once
> > > test.c:1: for each function it appears in.)
> > > 
> > > I think the error message is perfectly clear without that.
> > 
> > I'd agree with this too.  Maybe GCC should have a beginner's mode?  :-)
> 
> how about --verbose-errors, and have both a one-line and paragraph
> explanation of each error?
> 
>   test.c:1: Message always goes here
>   test.c:1: (iff --verbose errors, extended explanation
>   test.c:1:  more...
>   test.c:1:  etc)
> 
> This way you can normally use the normal options, and stick in
> --verbose-errors when you see a new message or one you don't
> understand.

We've used almost exactly that approach in the Mercury compiler,
and IMHO it works reasonably well.

One drawback with this approach as you have outlined it is that
beginners, who are the ones that most need the verbose error messages,
don't know to use the `--verbose-errors' option.  To alleviate this
problem, at the end of all the compilation errors, the Mercury compiler
outputs the following additional message:

	Recompile with `--verbose-errors' for more information.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: < http://www.cs.mu.oz.au/~fjh >  |     -- the last words of T. S. Garp.

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

* Re: Really crummy error messages, was Re: Ada files now checked in
  2001-10-09 23:32       ` Fergus Henderson
@ 2001-10-10  2:25         ` Florian Weimer
  2001-10-10 11:00         ` Phil Edwards
  1 sibling, 0 replies; 9+ messages in thread
From: Florian Weimer @ 2001-10-10  2:25 UTC (permalink / raw)
  To: Fergus Henderson; +Cc: Tim Hollebeek, gcc

Fergus Henderson <fjh@cs.mu.oz.au> writes:

>> > > test.c:1: (Each undeclared identifier is reported only once
>> > > test.c:1: for each function it appears in.)

>> how about --verbose-errors, and have both a one-line and paragraph
>> explanation of each error?

> We've used almost exactly that approach in the Mercury compiler,
> and IMHO it works reasonably well.

The Ada compiler writes "(more references follow)" if the same
undeclared identifier is referenced multiple times.  Such an error
message is probably most helpful in this context, but I don't know if
you can implement it for the C compiler easily.

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

* Re: Really crummy error messages, was Re: Ada files now checked in
  2001-10-09 23:32       ` Fergus Henderson
  2001-10-10  2:25         ` Florian Weimer
@ 2001-10-10 11:00         ` Phil Edwards
  1 sibling, 0 replies; 9+ messages in thread
From: Phil Edwards @ 2001-10-10 11:00 UTC (permalink / raw)
  To: Fergus Henderson; +Cc: Tim Hollebeek, gcc

On Wed, Oct 10, 2001 at 04:31:33PM +1000, Fergus Henderson wrote:
> One drawback with this approach as you have outlined it is that
> beginners, who are the ones that most need the verbose error messages,
> don't know to use the `--verbose-errors' option.  To alleviate this
> problem, at the end of all the compilation errors, the Mercury compiler
> outputs the following additional message:
> 
> 	Recompile with `--verbose-errors' for more information.

I'd probably get just as annoyed seeing that message repeatedly as I
would seeing the "(each doohickey is reported only once for each flurble)"
message that started this subthread.  :-)

This is one of those few areas where I feel the compiler should take
parameters from an environment variable.  Maybe leave "beginner mode"
messages on by default, but allow others of us to set

    export GCC_DIAGNOSTICS=nobeginner,spaced_out,ANSI_color_highlights

to turn off the extra messages, and also do indenting like

    http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00318.html

with colors, etc.

Maybe only the driver would check for environment variables, and then insert
the appropriate -fdiagnostic options into the command line for the compiler.


Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams

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

* Re: Really crummy error messages, was Re: Ada files now checked in
  2001-10-08 13:31   ` Phil Edwards
  2001-10-08 16:49     ` Tim Hollebeek
@ 2001-10-11 14:04     ` Zack Weinberg
  1 sibling, 0 replies; 9+ messages in thread
From: Zack Weinberg @ 2001-10-11 14:04 UTC (permalink / raw)
  To: Phil Edwards; +Cc: Gabriel Dos Reis, dewar, fw, bosch, dnovillo, gcc, kenner

On Mon, Oct 08, 2001 at 04:32:25PM -0400, Phil Edwards wrote:
> On Mon, Oct 08, 2001 at 11:09:03AM -0700, Zack Weinberg wrote:
> > $ cat >test.c
> > int foo() { baz; }
> > $ gcc test.c
> > test.c: In function `foo':
> > test.c:1: `baz' undeclared (first use in this function)
> > test.c:1: (Each undeclared identifier is reported only once
> > test.c:1: for each function it appears in.)
> > $
> > 
> > Where is this "first use this function" coming from?
> 
> cp/lex.c, around line 1290.

Ah, the C++ compiler.  You didn't say which it was.

Hmm, there seems to be something else wrong:

$ cat test.c
int foo() { baz; }
int bar() { baz; }
$ g++ test.c
test.c: In function `int foo()':
test.c:1: `baz' undeclared (first use this function)
test.c:1: (Each undeclared identifier is reported only once for each function 
   it appears in.)

$ gcc test.c
test.c: In function `foo':
test.c:1: `baz' undeclared (first use in this function)
test.c:1: (Each undeclared identifier is reported only once
test.c:1: for each function it appears in.)
test.c: In function `bar':
test.c:2: `baz' undeclared (first use in this function)

They really ought to give identical error messages.

zw

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

end of thread, other threads:[~2001-10-11 14:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-07 14:34 Really crummy error messages, was Re: Ada files now checked in Phil Edwards
2001-10-07 23:01 ` Really crummy error messages Florian Weimer
2001-10-08 11:09 ` Really crummy error messages, was Re: Ada files now checked in Zack Weinberg
2001-10-08 13:31   ` Phil Edwards
2001-10-08 16:49     ` Tim Hollebeek
2001-10-09 23:32       ` Fergus Henderson
2001-10-10  2:25         ` Florian Weimer
2001-10-10 11:00         ` Phil Edwards
2001-10-11 14:04     ` Zack Weinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).