forked from OSchip/llvm-project
[Parser][ObjC] Make sure c++11 in-class initialization is done when the
constructor's definition is in an implementation block. 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 llvm-svn: 266645
This commit is contained in:
parent
05164816f0
commit
bd59b4894e
|
@ -3651,6 +3651,8 @@ void Parser::ParseLexedObjCMethodDefs(LexedMethod &LM, bool parseMethod) {
|
|||
else {
|
||||
if (Tok.is(tok::colon))
|
||||
ParseConstructorInitializer(MCDecl);
|
||||
else
|
||||
Actions.ActOnDefaultCtorInitializers(MCDecl);
|
||||
ParseFunctionStatementBody(MCDecl, BodyScope);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 *'
|
||||
|
||||
@interface NSObject
|
||||
@end
|
||||
|
||||
@interface I : NSObject
|
||||
@end
|
||||
|
||||
struct S {
|
||||
S();
|
||||
void *ptr = nullptr;
|
||||
};
|
||||
|
||||
@implementation I
|
||||
S::S() {}
|
||||
@end
|
Loading…
Reference in New Issue