[cfe-commits] r151515 - in /cfe/trunk: lib/Parse/ParseDeclCXX.cpp test/Parser/bracket-crash.cpp

Richard Smith richard at metafoo.co.uk
Sun Feb 26 22:08:38 PST 2012


On Sun, Feb 26, 2012 at 9:36 PM, David Blaikie <dblaikie at gmail.com> wrote:

> On Sun, Feb 26, 2012 at 9:24 PM, Richard Smith
> <richard-llvm at metafoo.co.uk> wrote:
> > Author: rsmith
> > Date: Sun Feb 26 23:24:00 2012
> > New Revision: 151515
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=151515&view=rev
> > Log:
> > Fix decltype crash-on-invalid, if we don't find a matching ')' for an
> ill-formed
> > decltype expression.
> >
> > Modified:
> >    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> >    cfe/trunk/test/Parser/bracket-crash.cpp
> >
> > Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=151515&r1=151514&r2=151515&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
> > +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sun Feb 26 23:24:00 2012
> > @@ -674,9 +674,9 @@
> >                                                  0, /*IsDecltype=*/true);
> >     Result = ParseExpression();
> >     if (Result.isInvalid()) {
> > -      SkipUntil(tok::r_paren, true, true);
> > +      SkipUntil(tok::r_paren);
> >       DS.SetTypeSpecError();
> > -      return Tok.is(tok::eof) ? Tok.getLocation() : ConsumeParen();
> > +      return StartLoc;
>
> If I recall correctly this return value is used to get the range of
> the decltype specifier - by returning StartLoc the range of the
> decltype expression will be a bit off. I realize it's an error case
> anyway, so I'm not sure how important that is, just a thought.
>

I considered this, but I'm not too concerned about the source range
covering just the decltype token in the case where the parenthesized
expression is malformed. If we find a case where it causes bad diagnostics
for later errors, we can fix it, but otherwise I don't think there's much
point.

- Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120226/4e896a9a/attachment.html>


More information about the cfe-commits mailing list