[PATCH] Fix generating TypeSourceInfo for invalid array type

Richard Smith richard at metafoo.co.uk
Tue Aug 5 19:48:00 PDT 2014


On Tue, Aug 5, 2014 at 3:16 PM, Olivier Goffart <ogoffart at woboq.com> wrote:

> Hi,
>
> This fixes a crash in the RecursiveASTVisitor on such code:
>  __typeof__(struct F*) var[invalid];
>
> The main problem is that when the type is invalid, we don't even
> try to generate TypeSourceInfo for it, which lead to a crash when we try
> to visit them in the tools.
> This is solved in SemaType.cpp by actually generating the TypeSourceInfo
> even for invalid types.
>

I'm surprised by this: the code used to call getTrivialTypeSourceInfo in
this case, which does create a TypeSourceInfo object. How do we end up with
the TSI being null?


> The second problem is that if there is an error parsing the size of the
> array, we bail out without actually registering that it should have been an
> array. Fix that Parser::ParseBracketDeclarator.
> Move the check for invalid type a bit up in Sema::ActOnUninitializedDecl
> in order to avoid unnecessary diagnostic


This part looks fine. Is it possible to add a testcase for the improved
recovery here, without the rest of the patch?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140805/60b98161/attachment.html>


More information about the cfe-commits mailing list