On 20 Feb 2016, at 08:33, Alex Denisov <[email protected]> wrote: >> On 20 Feb 2016, at 01:57, Steve Kargl <[email protected]> >> wrote: >> >> If anyone is interesting fixing FreeBSD's C compiler, it >> would be appreciated. ... >> foo.c:21:1: error: use of undeclared identifier 'corrupt'; did you mean >> 'crypt'? >> corrupt: >> ^~~~~~~ >> crypt >> /usr/include/unistd.h:450:7: note: 'crypt' declared here >> char *crypt(const char *, const char *); >> ^ >> foo.c:21:8: error: expected ';' after return statement >> corrupt: >> ^ >> ; >> foo.c:14:12: error: use of undeclared label 'corrupt' >> goto corrupt; >> ^ ... > I’ve submitted the bug to LLVM’s bugzilla: > https://llvm.org/bugs/show_bug.cgi?id=26678 > > Also, it looks like OS agnostic. At least I see the same behaviour on OSX as > well.
Yes, the messages could definitely be improved. But for a compiler, it
is sometimes hard to guess the 'intent' of the code, though. :)
Note that gcc (I used 6.0 from ports) gives similarly confused messages:
foo.c: In function 'foo':
foo.c:21:1: error: 'corrupt' undeclared (first use in this function)
corrupt:
^~~~~~~
foo.c:21:1: note: each undeclared identifier is reported only once for each
function it appears in
foo.c:21:1: warning: 'return' with a value, in function returning void
foo.c:5:1: note: declared here
foo(int i)
^~~
foo.c:21:8: error: expected ';' before ':' token
corrupt:
^
foo.c:14:6: error: label 'corrupt' used but not defined
goto corrupt;
^~~~
In gcc's case, it appears to read the statement as "return corrupt:",
causing it to first complain about the undeclared identifier, and then
about a missing semicolon. Later, the label is of course still not
defined, so it complains again.
-Dimitry
signature.asc
Description: Message signed with OpenPGP using GPGMail
