diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-25 22:31:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-25 22:31:57 +0000 |
commit | 523382640e9b099dd64ba0875a60a9356845b068 (patch) | |
tree | 839455cbcd570db84299d6e8bb705530ac4da572 /lib/Sema/SemaType.cpp | |
parent | 38fd4d001182b0b125a42c3b7e83e9dbac50e8a5 (diff) |
Implement rdar://6756623 - use of deprecated type in deprecated typedef should not warn
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85073 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r-- | lib/Sema/SemaType.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 01490fc69f..029aecc045 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -67,6 +67,16 @@ static bool isOmittedBlockReturnType(const Declarator &D) { return false; } +/// isDeclaratorDeprecated - Return true if the declarator is deprecated. +/// We do not want to warn about use of deprecated types (e.g. typedefs) when +/// defining a declaration that is itself deprecated. +static bool isDeclaratorDeprecated(const Declarator &D) { + for (const AttributeList *AL = D.getAttributes(); AL; AL = AL->getNext()) + if (AL->getKind() == AttributeList::AT_deprecated) + return true; + return false; +} + /// \brief Convert the specified declspec to the appropriate type /// object. /// \param D the declarator containing the declaration specifier. @@ -237,7 +247,8 @@ static QualType ConvertDeclSpecToType(Declarator &TheDeclarator, Sema &TheSema){ } // If the type is deprecated or unavailable, diagnose it. - TheSema.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeLoc()); + TheSema.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeLoc(), + isDeclaratorDeprecated(TheDeclarator)); assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 && DS.getTypeSpecSign() == 0 && "No qualifiers on tag names!"); @@ -298,15 +309,18 @@ static QualType ConvertDeclSpecToType(Declarator &TheDeclarator, Sema &TheSema){ TheDeclarator.setInvalidType(true); // If the type is deprecated or unavailable, diagnose it. - TheSema.DiagnoseUseOfDecl(TDT->getDecl(), DS.getTypeSpecTypeLoc()); + TheSema.DiagnoseUseOfDecl(TDT->getDecl(), DS.getTypeSpecTypeLoc(), + isDeclaratorDeprecated(TheDeclarator)); } else if (ObjCInterfaceType *OIT = dyn_cast<ObjCInterfaceType>(Result)) { // If the type is deprecated or unavailable, diagnose it. - TheSema.DiagnoseUseOfDecl(OIT->getDecl(), DS.getTypeSpecTypeLoc()); + TheSema.DiagnoseUseOfDecl(OIT->getDecl(), DS.getTypeSpecTypeLoc(), + isDeclaratorDeprecated(TheDeclarator)); } 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()); + TheSema.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeLoc(), + isDeclaratorDeprecated(TheDeclarator)); } |