On Sun, Jul 19, 2015 at 12:37 AM, Davide Italiano <dccitali...@gmail.com> wrote:
> davide created this revision.
> davide added reviewers: rsmith, mclow.lists.
> davide added a subscriber: cfe-commits.
>
> I originally tried to fix this in SemaExpr (ActOnCallExpr), putting this 
> check just before BuildCallToMemberFunction() call, but eventaully convinced 
> myself SemaOverload should be the right place to fix.

I'll let Richard comment on whether this is the correct place for the
fix or not, but some comments below.

>
> Thanks,
>
> --
> Davide
>
> http://reviews.llvm.org/D11334
>
> Files:
>   lib/Sema/SemaOverload.cpp
>   test/SemaCXX/deleted-function-access.cpp
>
> Index: test/SemaCXX/deleted-function-access.cpp
> ===================================================================
> --- test/SemaCXX/deleted-function-access.cpp
> +++ test/SemaCXX/deleted-function-access.cpp
> @@ -0,0 +1,4 @@
> +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
> +
> +struct S { virtual void f() = delete;
> +            void g() { f(); } }; //expected-error{{call to deleted member 
> function f}}

This code is formatted a bit oddly.

> Index: lib/Sema/SemaOverload.cpp
> ===================================================================
> --- lib/Sema/SemaOverload.cpp
> +++ lib/Sema/SemaOverload.cpp
> @@ -11604,6 +11604,15 @@
>      FoundDecl = MemExpr->getFoundDecl();
>      Qualifier = MemExpr->getQualifier();
>      UnbridgedCasts.restore();
> +
> +    // Calls to deleted member functions are verboten.
> +    if (Method && Method->isDeleted()) {

You should elide the braces.

> +      Diag(MemExpr->getLocStart(), diag::err_ovl_deleted_member_call)
> +      << true /* isDeleted */
> +      << Method->getName()

You should just pass in Method instead of getName(); that will ensure
the diagnostic is quoted properly.

> +      << std::string() /* getDeletedOrUnavailableSuffix */

Why not call getDeletedOrUnavailableSuffix()?

> +      << MemExpr->getSourceRange();
> +    }
>    } else {
>      UnresolvedMemberExpr *UnresExpr = 
> cast<UnresolvedMemberExpr>(NakedMemExpr);
>      Qualifier = UnresExpr->getQualifier();

~Aaron
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to