diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-18 21:56:37 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-18 21:56:37 +0000 |
commit | 48f3bb9f780f6e64ab71ba0202ca04b07473805a (patch) | |
tree | df7ad34f04fbb5b8a22e75e34e31471a6ee6d511 /lib/Sema/SemaDecl.cpp | |
parent | 4fd83ea566f4a0c083001c84b75da6cc8c99c1d6 (diff) |
Downgrade complaints about calling unavailable functions to a warning
(as GCC does), except when we've performed overload resolution and
found an unavailable function: in this case, we actually error.
Merge the checking of unavailable functions with the checking for
deprecated functions. This unifies a bit of code, and makes sure that
we're checking for unavailable functions in the right places. Also,
this check can cause an error. We may, eventually, want an option to
make "unavailable" warnings into errors.
Implement much of the logic needed for C++0x deleted functions, which
are effectively the same as "unavailable" functions (but always cause
an error when referenced). However, we don't have the syntax to
specify deleted functions yet :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64955 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 661124c579..a276f3c1ce 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -64,15 +64,15 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, if (IIDecl) { if (TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) { - // If this typename is deprecated, emit a warning. - DiagnoseUseOfDeprecatedDecl(IIDecl, NameLoc); + // Check whether we can use this type + (void)DiagnoseUseOfDecl(IIDecl, NameLoc); return Context.getTypeDeclType(TD).getAsOpaquePtr(); } if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(IIDecl)) { - // If this typename is deprecated, emit a warning. - DiagnoseUseOfDeprecatedDecl(IIDecl, NameLoc); + // Check whether we can use this interface. + (void)DiagnoseUseOfDecl(IIDecl, NameLoc); return Context.getObjCInterfaceType(IDecl).getAsOpaquePtr(); } @@ -591,6 +591,11 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { if (OldQType == NewQType) { // We have a redeclaration. MergeAttributes(New, Old); + + // Merge the "deleted" flag. + if (Old->isDeleted()) + New->setDeleted(); + return MergeCXXFunctionDecl(New, Old); } @@ -635,6 +640,10 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { } MergeAttributes(New, Old); + + // Merge the "deleted" flag. + if (Old->isDeleted()) + New->setDeleted(); return false; } @@ -3125,8 +3134,8 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK, } if (PrevDecl) { - // If the previous declaration was deprecated, emit a warning. - DiagnoseUseOfDeprecatedDecl(PrevDecl, NameLoc); + // Check whether the previous declaration is usable. + (void)DiagnoseUseOfDecl(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 |