r266645 - [Parser][ObjC] Make sure c++11 in-class initialization is done when the

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 18 19:28:14 PDT 2016


Thanks for catching this, r266706.

> On Apr 18, 2016, at 11:38 AM, Richard Smith <richard at metafoo.co.uk> wrote:
> 
> On Mon, Apr 18, 2016 at 11:19 AM, Akira Hatanaka via cfe-commits <cfe-commits at lists.llvm.org <mailto:cfe-commits at lists.llvm.org>> wrote:
> Author: ahatanak
> Date: Mon Apr 18 13:19:45 2016
> New Revision: 266645
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=266645&view=rev <http://llvm.org/viewvc/llvm-project?rev=266645&view=rev>
> Log:
> [Parser][ObjC] Make sure c++11 in-class initialization is done when the
> constructor's definition is in an implementation block.
> 
> This doesn't just fix the C++11 case, it also fixes this:
> 
> struct Q { Q(); };
> struct S { S(); Q q;  };
> 
> @implementation I
> S::S() {}
> @end
> 
> We previously did not run the Q default constructor from the S default constructor.
> 
> Can you also add that to the test, please?
> 
> Without this commit, ptr doesn't get initialized to null in the
> following code:
> 
> struct S {
>   S();
>   void *ptr = nullptr;
> };
> 
> @implementation I
>   S::S() {}
> @end
> 
> rdar://problem/25693624
> 
> Added:
>     cfe/trunk/test/Parser/objc-default-ctor-init.mm <https://urldefense.proofpoint.com/v2/url?u=http-3A__objc-2Ddefault-2Dctor-2Dinit.mm&d=BQMFaQ&c=Hw-EJUFt2_D9PK5csBJ29kRV40HqSDXWTLPyZ6W8u84&r=WE8Ob6C4AXEAwDpQ1eJKZaHrd05IdBJKmcim2GmXr8Q&m=2HssnazEfepis4JB2nsgaJoLetc07fMAma9p69NVGkY&s=a8F3E2MsE347H22C4F1y4SIv43f9H5WNPeiVaigwWyo&e=>
> Modified:
>     cfe/trunk/lib/Parse/ParseObjc.cpp
> 
> Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=266645&r1=266644&r2=266645&view=diff <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=266645&r1=266644&r2=266645&view=diff>
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseObjc.cpp Mon Apr 18 13:19:45 2016
> @@ -3651,6 +3651,8 @@ void Parser::ParseLexedObjCMethodDefs(Le
>    else {
>      if (Tok.is(tok::colon))
>        ParseConstructorInitializer(MCDecl);
> +    else
> +      Actions.ActOnDefaultCtorInitializers(MCDecl);
>      ParseFunctionStatementBody(MCDecl, BodyScope);
>    }
> 
> 
> Added: cfe/trunk/test/Parser/objc-default-ctor-init.mm <https://urldefense.proofpoint.com/v2/url?u=http-3A__objc-2Ddefault-2Dctor-2Dinit.mm&d=BQMFaQ&c=Hw-EJUFt2_D9PK5csBJ29kRV40HqSDXWTLPyZ6W8u84&r=WE8Ob6C4AXEAwDpQ1eJKZaHrd05IdBJKmcim2GmXr8Q&m=2HssnazEfepis4JB2nsgaJoLetc07fMAma9p69NVGkY&s=a8F3E2MsE347H22C4F1y4SIv43f9H5WNPeiVaigwWyo&e=>
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-default-ctor-init.mm?rev=266645&view=auto <http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-default-ctor-init.mm?rev=266645&view=auto>
> ==============================================================================
> --- cfe/trunk/test/Parser/objc-default-ctor-init.mm <https://urldefense.proofpoint.com/v2/url?u=http-3A__objc-2Ddefault-2Dctor-2Dinit.mm&d=BQMFaQ&c=Hw-EJUFt2_D9PK5csBJ29kRV40HqSDXWTLPyZ6W8u84&r=WE8Ob6C4AXEAwDpQ1eJKZaHrd05IdBJKmcim2GmXr8Q&m=2HssnazEfepis4JB2nsgaJoLetc07fMAma9p69NVGkY&s=a8F3E2MsE347H22C4F1y4SIv43f9H5WNPeiVaigwWyo&e=> (added)
> +++ cfe/trunk/test/Parser/objc-default-ctor-init.mm <https://urldefense.proofpoint.com/v2/url?u=http-3A__objc-2Ddefault-2Dctor-2Dinit.mm&d=BQMFaQ&c=Hw-EJUFt2_D9PK5csBJ29kRV40HqSDXWTLPyZ6W8u84&r=WE8Ob6C4AXEAwDpQ1eJKZaHrd05IdBJKmcim2GmXr8Q&m=2HssnazEfepis4JB2nsgaJoLetc07fMAma9p69NVGkY&s=a8F3E2MsE347H22C4F1y4SIv43f9H5WNPeiVaigwWyo&e=> Mon Apr 18 13:19:45 2016
> @@ -0,0 +1,17 @@
> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -std=c++11 -ast-dump %s | FileCheck %s
> +// CHECK: CXXCtorInitializer Field {{.*}} 'ptr' 'void *'
> +
> + at interface NSObject
> + at end
> +
> + at interface I : NSObject
> + at end
> +
> +struct S {
> +  S();
> +  void *ptr = nullptr;
> +};
> +
> + at implementation I
> +S::S() {}
> + at end
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org <mailto:cfe-commits at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits>
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160418/d83d01bb/attachment-0001.html>


More information about the cfe-commits mailing list