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

David Blaikie dblaikie at gmail.com
Sun Feb 26 21:36:12 PST 2012


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.

- David

>     }
>
>     // Match the ')'
>
> Modified: cfe/trunk/test/Parser/bracket-crash.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/bracket-crash.cpp?rev=151515&r1=151514&r2=151515&view=diff
> ==============================================================================
> --- cfe/trunk/test/Parser/bracket-crash.cpp (original)
> +++ cfe/trunk/test/Parser/bracket-crash.cpp Sun Feb 26 23:24:00 2012
> @@ -1,6 +1,6 @@
> -// RUN: not %clang_cc1 -fsyntax-only %s
> +// RUN: not %clang_cc1 -fsyntax-only -std=c++11 %s
>  // PR7481
> +decltype(;
>  struct{
>   a
>  }
> -
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list