[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:
Akira Hatanaka 2016-04-18 18:19:45 +00:00
parent 05164816f0
commit bd59b4894e
2 changed files with 19 additions and 0 deletions

View File

@ -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);
}

View File

@ -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