r225768 - Parse: Don't crash if missing an initializer expression

Nico Weber thakis at chromium.org
Sat Jan 17 17:33:22 PST 2015


On Mon, Jan 12, 2015 at 9:28 PM, David Majnemer <david.majnemer at gmail.com>
wrote:

> Author: majnemer
> Date: Mon Jan 12 23:28:24 2015
> New Revision: 225768
>
> URL: http://llvm.org/viewvc/llvm-project?rev=225768&view=rev
> Log:
> Parse: Don't crash if missing an initializer expression
>
> Modified:
>     cfe/trunk/lib/Parse/ParseDecl.cpp
>     cfe/trunk/test/Parser/cxx-default-args.cpp
>
> Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=225768&r1=225767&r2=225768&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Jan 12 23:28:24 2015
> @@ -5625,13 +5625,14 @@ void Parser::ParseParameterDeclarationCl
>            // FIXME: Can we use a smart pointer for Toks?
>            DefArgToks = new CachedTokens;
>
> +          SourceLocation ArgStartLoc = NextToken().getLocation();
>            if (!ConsumeAndStoreInitializer(*DefArgToks,
> CIK_DefaultArgument)) {
>              delete DefArgToks;
>              DefArgToks = nullptr;
>              Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
>

Shouldn't your test case go down this path?


>            } else {
>              Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
> -
> (*DefArgToks)[1].getLocation());
> +                                                      ArgStartLoc);
>            }
>          } else {
>            // Consume the '='.
>
> Modified: cfe/trunk/test/Parser/cxx-default-args.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-default-args.cpp?rev=225768&r1=225767&r2=225768&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Parser/cxx-default-args.cpp (original)
> +++ cfe/trunk/test/Parser/cxx-default-args.cpp Mon Jan 12 23:28:24 2015
> @@ -36,3 +36,7 @@ struct T {
>  struct S {
>    void f(int &r = error);  // expected-error {{use of undeclared
> identifier 'error'}}
>  };
> +
> +struct U {
> +  void i(int x = ) {} // expected-error{{expected expression}}
> +};
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150117/13b6ddc1/attachment.html>


More information about the cfe-commits mailing list