Index: cfe/trunk/lib/Sema/SemaDeclObjC.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp @@ -1210,6 +1210,11 @@ PDecl = ObjCProtocolDecl::Create(Context, CurContext, ProtocolName, ProtocolLoc, AtProtoInterfaceLoc, /*PrevDecl=*/nullptr); + + // If we are using modules, add the decl to the context in order to + // serialize something meaningful. + if (getLangOpts().Modules) + PushOnScopeChains(PDecl, TUScope); PDecl->startDefinition(); } else { if (PrevDecl) { Index: cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h =================================================================== --- cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h +++ cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h @@ -0,0 +1,3 @@ +@protocol Foo +- (void)someMethodOnFoo; +@end Index: cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap =================================================================== --- cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap +++ cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap @@ -0,0 +1,4 @@ +framework module Base { + header "Base.h" + export * +} \ No newline at end of file Index: cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h =================================================================== --- cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h +++ cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h @@ -0,0 +1,6 @@ +#import + +// REDECLARATION +@protocol Foo +- (void)someMethodOnFoo; +@end Index: cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap =================================================================== --- cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap +++ cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap @@ -0,0 +1,4 @@ +framework module Kit { + header "Kit.h" + export * +} \ No newline at end of file Index: cfe/trunk/test/Modules/protocol-redefinition.m =================================================================== --- cfe/trunk/test/Modules/protocol-redefinition.m +++ cfe/trunk/test/Modules/protocol-redefinition.m @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F%S/Inputs/protocol-redefinition -fsyntax-only %s -Wno-private-module -verify + +// expected-no-diagnostics + +@import Kit;