aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-16 22:07:16 +0000
committerChris Lattner <sabre@nondot.org>2009-02-16 22:07:16 +0000
commit22bd905673a73ccb9b5e45a7038ec060c9650ffe (patch)
treed907a8134b6145740a9836de4d74a1d58fb9f583 /lib/Sema/SemaDecl.cpp
parent6175dc676c515a74e5f41afb4ac2b44cc2367a24 (diff)
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
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp44
1 files changed, 29 insertions, 15 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 5d02b66f36..2692cd99db 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -43,30 +43,41 @@ using namespace clang;
/// 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 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
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