Skip to content

Commit

Permalink
Add protocol redefinition to the current scope/context
Browse files Browse the repository at this point in the history
Not doing so causes the AST writter to assert since the decl in question
never gets emitted. This is fine when modules is not used, but otherwise
we need to serialize something other than garbage.

rdar://problem/39844933

Differential Revision: https://reviews.llvm.org/D47297

llvm-svn: 336031
  • Loading branch information
bcardosolopes committed Jun 30, 2018
1 parent 7c557f8 commit 7dcf23e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clang/lib/Sema/SemaDeclObjC.cpp
Expand Up @@ -1210,6 +1210,11 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc,
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) {
Expand Down
@@ -0,0 +1,3 @@
@protocol Foo
- (void)someMethodOnFoo;
@end
@@ -0,0 +1,4 @@
framework module Base {
header "Base.h"
export *
}
@@ -0,0 +1,6 @@
#import <Base/Base.h>

// REDECLARATION
@protocol Foo
- (void)someMethodOnFoo;
@end
@@ -0,0 +1,4 @@
framework module Kit {
header "Kit.h"
export *
}
6 changes: 6 additions & 0 deletions clang/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;

0 comments on commit 7dcf23e

Please sign in to comment.