diagnose uses of deprecated typenames and tags.
We now pass all the deprecation tests in the objc.dg suite.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64679 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 5d02b66..2692cd9 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -43,30 +43,41 @@
/// and then return NULL.
Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
Scope *S, const CXXScopeSpec *SS) {
- Decl *IIDecl = 0;
+ NamedDecl *IIDecl = 0;
LookupResult Result = LookupParsedName(S, SS, &II, LookupOrdinaryName,
false, false);
switch (Result.getKind()) {
- case LookupResult::NotFound:
- case LookupResult::FoundOverloaded:
- return 0;
+ case LookupResult::NotFound:
+ case LookupResult::FoundOverloaded:
+ return 0;
- case LookupResult::AmbiguousBaseSubobjectTypes:
- case LookupResult::AmbiguousBaseSubobjects:
- case LookupResult::AmbiguousReference:
- DiagnoseAmbiguousLookup(Result, DeclarationName(&II), NameLoc);
- return 0;
+ case LookupResult::AmbiguousBaseSubobjectTypes:
+ case LookupResult::AmbiguousBaseSubobjects:
+ case LookupResult::AmbiguousReference:
+ DiagnoseAmbiguousLookup(Result, DeclarationName(&II), NameLoc);
+ return 0;
- case LookupResult::Found:
- IIDecl = Result.getAsDecl();
- break;
+ case LookupResult::Found:
+ IIDecl = Result.getAsDecl();
+ break;
}
if (IIDecl) {
- if (TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl))
+ if (TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
+ // If this typename is deprecated, emit a warning.
+ DiagnoseUseOfDeprecatedDecl(IIDecl, NameLoc);
+
return Context.getTypeDeclType(TD).getAsOpaquePtr();
- else if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(IIDecl))
+ }
+
+ if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(IIDecl)) {
+ // If this typename is deprecated, emit a warning.
+ DiagnoseUseOfDeprecatedDecl(IIDecl, NameLoc);
+
return Context.getObjCInterfaceType(IDecl).getAsOpaquePtr();
+ }
+
+ // Otherwise, could be a variable, function etc.
}
return 0;
}
@@ -3091,7 +3102,10 @@
PrevDecl = 0;
}
- if (PrevDecl) {
+ if (PrevDecl) {
+ // If the previous declaration was deprecated, emit a warning.
+ DiagnoseUseOfDeprecatedDecl(PrevDecl, NameLoc);
+
if (TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
// If this is a use of a previous tag, or if the tag is already declared
// in the same scope (so that the definition/declaration completes or
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index b82c50a..dee352b 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -111,7 +111,7 @@
// Diagnose classes that inherit from deprecated classes.
if (SuperClassDecl)
- DiagnoseUseOfDeprecatedDeclImpl(SuperClassDecl, SuperLoc);
+ DiagnoseUseOfDeprecatedDecl(SuperClassDecl, SuperLoc);
if (PrevDecl && SuperClassDecl == 0) {
// The previous declaration was not a class decl. Check if we have a
@@ -270,7 +270,7 @@
continue;
}
- DiagnoseUseOfDeprecatedDeclImpl(PDecl, ProtocolId[i].second);
+ DiagnoseUseOfDeprecatedDecl(PDecl, ProtocolId[i].second);
// If this is a forward declaration and we are supposed to warn in this
// case, do it.
@@ -493,7 +493,7 @@
CDecl->setClassInterface(IDecl);
// If the interface is deprecated, warn about it.
- DiagnoseUseOfDeprecatedDeclImpl(IDecl, ClassLoc);
+ DiagnoseUseOfDeprecatedDecl(IDecl, ClassLoc);
/// Check for duplicate interface declaration for this category
ObjCCategoryDecl *CDeclChain;