patch: clarify missing template arguments when parsing base specifier
Arthur O'Dwyer
arthur.j.odwyer at gmail.com
Mon Aug 26 23:03:14 PDT 2013
On Mon, Aug 26, 2013 at 10:38 PM, Nick Lewycky <nlewycky at google.com> wrote:
>
> template <typename T> class Foo {}; class Bar : public Foox {};
>
> before my patch, clang emits:
>
> a.cc:1:56: error: expected class name
> [point at 'Foox']
>
> and with my patch clang emits:
>
> a.cc:1:56: error: no template named 'Foox'; did you mean 'Foo'?
Chandler's response confirms that this new message is far too
confusing for mere mortals. ;) I infer that what happens here is that
we see "Foox", edit-distance it to "Foo", decide that the user meant
"Foo", and then "helpfully" proclaim that there is "no template named
Foox" simply because Foo itself happens to be a template; if Foo were
a namespace instead, we'd proclaim "no namespace named Foox", and so
on.
I think a more helpful message would be to always say "error: no class
or class template named Foox", regardless of whatever sort of entity
the error-corrected Foo happens to be. I.e., the error message should
describe what Clang *expected* to find there, not what it *did*
(modulo typos) find there.
–Arthur
More information about the cfe-commits
mailing list