From 78713d86faeaaabb8aeb1683353e791defd3a3bf Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 9 Apr 2010 21:30:38 +0000 Subject: [PATCH] When upgrading an Objective-C class from a forward declaration to a full-fledged @interface, be sure that the declaration has the right lexical context. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100903 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclObjC.cpp | 1 + test/SemaObjCXX/linkage-spec.mm | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 7e5e40c562..eb3f4222b6 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -98,6 +98,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc, // Since this ObjCInterfaceDecl was created by a forward declaration, // we now add it to the DeclContext since it wasn't added before // (see ActOnForwardClassDeclaration). + IDecl->setLexicalDeclContext(CurContext); CurContext->addDecl(IDecl); if (AttrList) diff --git a/test/SemaObjCXX/linkage-spec.mm b/test/SemaObjCXX/linkage-spec.mm index b4e809eee1..1454e6a678 100644 --- a/test/SemaObjCXX/linkage-spec.mm +++ b/test/SemaObjCXX/linkage-spec.mm @@ -2,3 +2,11 @@ extern "C" { @class Protocol; } + +// +extern "C" { +@class I; +} + +@interface I +@end -- 2.40.0