Clang error recovery

Robert Clipsham robert at octarineparrot.com
Tue Apr 6 05:56:49 PDT 2010


On 06/04/10 13:05, bearophile wrote:
> Here Clangs gives a single error message (and it gives the error column).

The error column won't happen in DMD, Walter has mentioned many times 
before that no one ever commented on the feature, and no one seemed to 
care when it disappeared... Maybe this will change as clang increases in 
popularity? That said, with properly formatted code it's generally not 
hard to find where your error is, as there isn't much on a line.

I also like the idea of giving a single error message. Most of the time 
when I have a nice list of errors I skim through and look for identifier 
names where I forgot to import a module, or pick out some line numbers 
that seem to have to first error on and jump to them in my editor... 
Both of these would be easier to do with only one error message.

> Here the errors given by dmd give the same information.
> Here dmd gives error messages that are better than GCC 4.2 ones, but I think a single good error message is better than three.

I agree here, those extra errors can be a pain sometimes when you're 
trying to find the actual cause.
> temp.d(2): Error: identifier 'uint64' is not defined
> temp.d(2): Error: uint64 is used as a type
> temp.d(2): Error: cannot have parameter of type void
>
>
> That page says:
>
>> Code that later used 'x', for example, knows that it is declared as an int64_t, so it doesn't lead to other weird follow on errors that don't make any sense.<

I don't think the spell checker has been implemented for types, just 
identifiers... If this is the case then it shouldn't take much to add in 
the spell checking. As for later error messages, that will take more 
effort, although I would imagine it would just require changing the type 
to the spell checked type internally to avid the later errors.

> But I don't understand what it means. Maybe this is why this blog post is titled "Clang Error Recovery" instead of "Clang Error Messages".

It means that clang knows the type give is incorrect, so when it 
continues analyzing the code it will pretend you gave (what it thinks 
is) the right type, rather than giving more errors because you gave the 
incorrect type.

> Later in the same post it says something similar:
>
>> In addition to getting the error message right (and suggesting a fixit replacement to "::"), Clang "knows what you mean" so it handles the subsequent uses of a2 correctly.<

This is the same thing as above.

> temp.d(10): Error: incompatible types for ((a) + (b)): 'x' and 'y'
> temp.d(10): Error: + has no effect in expression ((__error) + (__error))

Other than the column, this gives roughly the same information. I guess 
the only way to improve here would be to remove the second error, but 
it's not really much of an issue.

>
> Bye,
> bearophile




More information about the Digitalmars-d mailing list