[cfe-dev] A bug?
Richard Smith
richard at metafoo.co.uk
Fri Jun 28 14:24:27 PDT 2013
On Fri, Jun 28, 2013 at 8:54 AM, Pan, Wei <wei.pan at intel.com> wrote:
> With the following example,
>
> struct A { ~A(); };
>
> void foo() {
> A a = 1 + A(); // bad initializer to a
> int i = 0;
> }
>
> The AST for the second statement "int i = 0;" is
>
> `-DeclStmt 0x3f0cb60 <line:9:3, col:12>
> `-VarDecl 0x3f0cad0 <col:3, col:11> b 'int'
> `-ExprWithCleanups 0x3f0cb48 <col:11> 'int'
> `-IntegerLiteral 0x3f0cb28 <col:11> 'int' 1
>
> which looks bad to have an extra "ExprWithCleanups" node.
>
> Does the following simple change fix it properly? Thanks!
>
> Wei
>
> --------------- inlined patch -----------------
>
> diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
> index 451bf95..8f0c7ae 100644
> --- a/lib/Parse/ParseDecl.cpp
> +++ b/lib/Parse/ParseDecl.cpp
> @@ -1933,6 +1933,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(Declarator &D,
> }
>
> Actions.FinalizeDeclaration(ThisDecl);
> + Actions.DiscardCleanupsInEvaluationContext();
This should probably be in ActOnInitializerError.
More information about the cfe-dev
mailing list