[PATCH] D11334: [Sema] Call to deleted functions are supposed to be verboten
Davide Italiano
dccitaliano at gmail.com
Sat Jul 18 21:37:12 PDT 2015
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.
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}}
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()) {
+ Diag(MemExpr->getLocStart(), diag::err_ovl_deleted_member_call)
+ << true /* isDeleted */
+ << Method->getName()
+ << std::string() /* getDeletedOrUnavailableSuffix */
+ << MemExpr->getSourceRange();
+ }
} else {
UnresolvedMemberExpr *UnresExpr = cast<UnresolvedMemberExpr>(NakedMemExpr);
Qualifier = UnresExpr->getQualifier();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11334.30105.patch
Type: text/x-patch
Size: 1179 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150719/ba2651c2/attachment.bin>
More information about the cfe-commits
mailing list