aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-10-06 23:23:20 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-10-06 23:23:20 +0000
commit3a387441ae339363ee5b254658f295e97bd9e913 (patch)
tree4e39ccc7508ba46e5fa86a101f215ff736cc894e /lib/Sema
parent51c3b79caa493a53d324190c0d7e3cd1fe93d4f3 (diff)
When using an unavailable/deprecated interface Foo inside Foo's interface/implementation
don't emit unavailable errors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141334 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/Sema.cpp3
-rw-r--r--lib/Sema/SemaDecl.cpp15
-rw-r--r--lib/Sema/SemaDeclAttr.cpp2
-rw-r--r--lib/Sema/SemaDeclObjC.cpp18
-rw-r--r--lib/Sema/SemaExpr.cpp3
5 files changed, 27 insertions, 14 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 679d4f6589..3f47986367 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -95,7 +95,8 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
LangOpts(pp.getLangOptions()), PP(pp), Context(ctxt), Consumer(consumer),
Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()),
CollectStats(false), ExternalSource(0), CodeCompleter(CodeCompleter),
- CurContext(0), PackContext(0), MSStructPragmaOn(false), VisContext(0),
+ CurContext(0), OriginalLexicalContext(0),
+ PackContext(0), MSStructPragmaOn(false), VisContext(0),
ExprNeedsCleanups(0), LateTemplateParser(0), OpaqueParser(0),
IdResolver(pp.getLangOptions()), CXXTypeInfoDecl(0), MSVCGuidDecl(0),
GlobalNewDeleteDeclared(false),
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 534cd488e7..4a4862bec4 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -8004,13 +8004,14 @@ void Sema::ActOnTagStartDefinition(Scope *S, Decl *TagD) {
PushDeclContext(S, Tag);
}
-void Sema::ActOnObjCContainerStartDefinition(Decl *IDecl) {
+Decl *Sema::ActOnObjCContainerStartDefinition(Decl *IDecl) {
assert(isa<ObjCContainerDecl>(IDecl) &&
"ActOnObjCContainerStartDefinition - Not ObjCContainerDecl");
DeclContext *OCD = cast<DeclContext>(IDecl);
assert(getContainingDC(OCD) == CurContext &&
"The next DeclContext should be lexically contained in the current one.");
CurContext = OCD;
+ return IDecl;
}
void Sema::ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagD,
@@ -8068,7 +8069,17 @@ void Sema::ActOnObjCContainerFinishDefinition() {
// Exit this scope of this interface definition.
PopDeclContext();
}
-
+
+void Sema::ActOnObjCTemporaryExitContainerContext() {
+ OriginalLexicalContext = CurContext;
+ ActOnObjCContainerFinishDefinition();
+}
+
+void Sema::ActOnObjCReenterContainerContext() {
+ ActOnObjCContainerStartDefinition(cast<Decl>(OriginalLexicalContext));
+ OriginalLexicalContext = 0;
+}
+
void Sema::ActOnTagDefinitionError(Scope *S, Decl *TagD) {
AdjustDeclIfTemplate(TagD);
TagDecl *Tag = cast<TagDecl>(TagD);
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 940f5a86a6..e5ea1610ad 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -4031,7 +4031,7 @@ void Sema::EmitDeprecationWarning(NamedDecl *D, StringRef Message,
}
// Otherwise, don't warn if our current context is deprecated.
- if (isDeclDeprecated(cast<Decl>(CurContext)))
+ if (isDeclDeprecated(cast<Decl>(getCurLexicalContext())))
return;
if (!Message.empty())
Diag(Loc, diag::warn_deprecated_message) << D->getDeclName()
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index de48de15d7..1a1ac2eccf 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -374,7 +374,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
// Return the previous class interface.
// FIXME: don't leak the objects passed in!
- return IDecl;
+ return ActOnObjCContainerStartDefinition(IDecl);
} else {
IDecl->setLocation(ClassLoc);
IDecl->setForwardDecl(false);
@@ -482,7 +482,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
}
CheckObjCDeclScope(IDecl);
- return IDecl;
+ return ActOnObjCContainerStartDefinition(IDecl);
}
/// ActOnCompatiblityAlias - this action is called after complete parsing of
@@ -578,7 +578,7 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc,
Diag(PDecl->getLocation(), diag::note_previous_definition);
// Just return the protocol we already had.
// FIXME: don't leak the objects passed in!
- return PDecl;
+ return ActOnObjCContainerStartDefinition(PDecl);
}
ObjCList<ObjCProtocolDecl> PList;
PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context);
@@ -611,7 +611,7 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc,
}
CheckObjCDeclScope(PDecl);
- return PDecl;
+ return ActOnObjCContainerStartDefinition(PDecl);
}
/// FindProtocolDeclaration - This routine looks up protocols and
@@ -741,7 +741,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
ClassLoc, CategoryLoc, CategoryName,IDecl);
CDecl->setInvalidDecl();
Diag(ClassLoc, diag::err_undef_interface) << ClassName;
- return CDecl;
+ return ActOnObjCContainerStartDefinition(CDecl);
}
if (!CategoryName && IDecl->getImplementation()) {
@@ -783,7 +783,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
}
CheckObjCDeclScope(CDecl);
- return CDecl;
+ return ActOnObjCContainerStartDefinition(CDecl);
}
/// ActOnStartCategoryImplementation - Perform semantic checks on the
@@ -836,7 +836,7 @@ Decl *Sema::ActOnStartCategoryImplementation(
}
CheckObjCDeclScope(CDecl);
- return CDecl;
+ return ActOnObjCContainerStartDefinition(CDecl);
}
Decl *Sema::ActOnStartClassImplementation(
@@ -930,7 +930,7 @@ Decl *Sema::ActOnStartClassImplementation(
ClassLoc, AtClassImplLoc);
if (CheckObjCDeclScope(IMPDecl))
- return IMPDecl;
+ return ActOnObjCContainerStartDefinition(IMPDecl);
// Check that there is no duplicate implementation of this class.
if (IDecl->getImplementation()) {
@@ -947,7 +947,7 @@ Decl *Sema::ActOnStartClassImplementation(
dyn_cast<NamedDecl>(IDecl),
IMPDecl->getLocation(), 1);
}
- return IMPDecl;
+ return ActOnObjCContainerStartDefinition(IMPDecl);
}
void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index ec71a4e94d..05b0bb7efc 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -72,7 +72,8 @@ static AvailabilityResult DiagnoseAvailabilityOfDecl(Sema &S,
break;
case AR_Unavailable:
- if (cast<Decl>(S.CurContext)->getAvailability() != AR_Unavailable) {
+ if (cast<Decl>(S.getCurLexicalContext())->getAvailability() !=
+ AR_Unavailable) {
if (Message.empty()) {
if (!UnknownObjCClass)
S.Diag(Loc, diag::err_unavailable) << D->getDeclName();