[cfe-commits] PATCH: Add a fixit hint to the error for an injected-class-name where one can't occur

Chandler Carruth chandlerc at google.com
Sun Jul 31 01:06:42 PDT 2011


Specifically, Clang currently errors on the following code:

struct X {};
X::X x;

As the type specifier 'X::X' isn't a valid use of the injected class name,
it instead names the constructor. The code in question performs error
recovery as if this *did* name the type already, but doesn't suggest a fixit
hint to make it actually name the type. This patch adds that fixit hint.

I have a tiny reservation here that there might be cases where the
suggestion change to the code doesn't actually match the recovery's
interpretation of 'X::X', specifically a context wherhe 'X' alone wouldn't
name a class type, but 'X::X' would if it were allowed. I don't think any
such case exists, but it might, so I wanted to run it by folks first.

My code doesn't fire for templates, one obvious case where the
injected-class-name is substantially different from the nominating name in
the NNS (in that the injected-class-name is a class-name, while the NNS
would end in a template-id). And the standard clarifies that base class's
injected-class-name can still be used in these contexts so it shouldn't fire
there.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110731/097c7091/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-icn-fixit-hint.patch
Type: text/x-patch
Size: 4254 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110731/097c7091/attachment.bin>


More information about the cfe-commits mailing list