[cfe-commits] r126499 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOverload.cpp test/SemaCXX/attr-unavailable.cpp
Douglas Gregor
dgregor at apple.com
Fri Feb 25 10:51:47 PST 2011
On Feb 25, 2011, at 10:38 AM, Fariborz Jahanian wrote:
> Author: fjahanian
> Date: Fri Feb 25 12:38:59 2011
> New Revision: 126499
>
> URL: http://llvm.org/viewvc/llvm-project?rev=126499&view=rev
> Log:
> Print optional message for attr(unavailable) in C++ mode.
> // rdar://9046492
Nifty. There are a bunch of other places where we print out a diagnostic for OR_Deleted; those likely need to be updated as well, and we could probably use some refactoring so that diagnostic logic only has to go in one place.
- Doug
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/test/SemaCXX/attr-unavailable.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=126499&r1=126498&r2=126499&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Feb 25 12:38:59 2011
> @@ -1312,6 +1312,8 @@
> "call to %0 is ambiguous">;
> def err_ovl_deleted_call : Error<
> "call to %select{unavailable|deleted}0 function %1">;
> +def err_ovl_unavailable_call : Error<
> + "call to unavailable function %0: %1">;
> def err_ovl_ambiguous_member_call : Error<
> "call to member function %0 is ambiguous">;
> def err_ovl_deleted_member_call : Error<
>
> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=126499&r1=126498&r2=126499&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Feb 25 12:38:59 2011
> @@ -7709,11 +7709,24 @@
> break;
>
> case OR_Deleted:
> - Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_deleted_call)
> - << Best->Function->isDeleted()
> - << ULE->getName()
> - << Fn->getSourceRange();
> - CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
> + {
> + llvm::StringRef Message;
> + if (const UnavailableAttr *UA =
> + Best->Function->getAttr<UnavailableAttr>())
> + Message = UA->getMessage();
> +
> + if (Message.empty())
> + Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_deleted_call)
> + << Best->Function->isDeleted()
> + << ULE->getName()
> + << Fn->getSourceRange();
> + else
> + Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_unavailable_call)
> + << ULE->getName()
> + << Message
> + << Fn->getSourceRange();
> + CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
> + }
> break;
> }
>
>
> Modified: cfe/trunk/test/SemaCXX/attr-unavailable.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-unavailable.cpp?rev=126499&r1=126498&r2=126499&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/attr-unavailable.cpp (original)
> +++ cfe/trunk/test/SemaCXX/attr-unavailable.cpp Fri Feb 25 12:38:59 2011
> @@ -18,3 +18,14 @@
> int &(*fp3)(int) = foo;
> void (*fp4)(...) = foo; // expected-error{{'foo' is unavailable}}
> }
> +
> +namespace radar9046492 {
> +// rdar://9046492
> +#define FOO __attribute__((unavailable("not available - replaced")))
> +
> +void foo() FOO; // expected-note {{candidate function has been explicitly made unavailable}}
> +
> +void bar() {
> + foo(); // expected-error {{call to unavailable function 'foo': not available - replaced}}
> +}
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list