diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-25 22:09:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-25 22:09:09 +0000 |
commit | a64ef0ab5cb6ac9cfb7d40661a9152c4aa488386 (patch) | |
tree | be3aef3e54bad6b57d314ac336a4188b89845d58 /lib/Sema/SemaType.cpp | |
parent | e37b3e6d7ed495fdec4067ccc1117a79d2afd450 (diff) |
move calls to DiagnoseUseOfDecl (which warns about deprecated/unavailable
types) out of Sema::getTypeName into ConvertDeclSpecToType. getTypeName
is sometimes used as a predicate in the parser, so it could cause redundant
diags to be emitted. This is also needed by two upcoming enhancements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85070 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r-- | lib/Sema/SemaType.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 50f1be2800..01490fc69f 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -58,11 +58,11 @@ static bool isOmittedBlockReturnType(const Declarator &D) { return false; if (D.getNumTypeObjects() == 0) - return true; + return true; // ^{ ... } if (D.getNumTypeObjects() == 1 && D.getTypeObject(0).Kind == DeclaratorChunk::Function) - return true; + return true; // ^(int X, float Y) { ... } return false; } @@ -228,7 +228,7 @@ static QualType ConvertDeclSpecToType(Declarator &TheDeclarator, Sema &TheSema){ case DeclSpec::TST_enum: case DeclSpec::TST_union: case DeclSpec::TST_struct: { - Decl *D = static_cast<Decl *>(DS.getTypeRep()); + TypeDecl *D = cast_or_null<TypeDecl>(static_cast<Decl *>(DS.getTypeRep())); if (!D) { // This can happen in C++ with ambiguous lookups. Result = Context.IntTy; @@ -236,11 +236,14 @@ static QualType ConvertDeclSpecToType(Declarator &TheDeclarator, Sema &TheSema){ break; } + // If the type is deprecated or unavailable, diagnose it. + TheSema.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeLoc()); + assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 && - DS.getTypeSpecSign() == 0 && - "Can't handle qualifiers on typedef names yet!"); + DS.getTypeSpecSign() == 0 && "No qualifiers on tag names!"); + // TypeQuals handled by caller. - Result = Context.getTypeDeclType(cast<TypeDecl>(D)); + Result = Context.getTypeDeclType(D); // In C++, make an ElaboratedType. if (TheSema.getLangOptions().CPlusPlus) { @@ -290,9 +293,22 @@ static QualType ConvertDeclSpecToType(Declarator &TheDeclarator, Sema &TheSema){ } // If this is a reference to an invalid typedef, propagate the invalidity. - if (TypedefType *TDT = dyn_cast<TypedefType>(Result)) + if (TypedefType *TDT = dyn_cast<TypedefType>(Result)) { if (TDT->getDecl()->isInvalidDecl()) TheDeclarator.setInvalidType(true); + + // If the type is deprecated or unavailable, diagnose it. + TheSema.DiagnoseUseOfDecl(TDT->getDecl(), DS.getTypeSpecTypeLoc()); + } else if (ObjCInterfaceType *OIT = dyn_cast<ObjCInterfaceType>(Result)) { + // If the type is deprecated or unavailable, diagnose it. + TheSema.DiagnoseUseOfDecl(OIT->getDecl(), DS.getTypeSpecTypeLoc()); + } else if (ObjCObjectPointerType *DPT = + dyn_cast<ObjCObjectPointerType>(Result)) { + // If the type is deprecated or unavailable, diagnose it. + if (ObjCInterfaceDecl *D = DPT->getInterfaceDecl()) + TheSema.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeLoc()); + } + // TypeQuals handled by caller. break; |