[PATCH] D11334: [Sema] Call to deleted functions are supposed to be verboten

Davide Italiano dccitaliano at gmail.com
Tue Jul 21 17:31:28 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL242857: [Sema] Diagnose use of declaration correctly. (authored by davide).

Changed prior to commit:
  http://reviews.llvm.org/D11334?vs=30288&id=30302#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11334

Files:
  cfe/trunk/lib/Sema/SemaExprMember.cpp
  cfe/trunk/test/SemaCXX/attr-deprecated.cpp
  cfe/trunk/test/SemaCXX/deleted-function-access.cpp

Index: cfe/trunk/test/SemaCXX/attr-deprecated.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/attr-deprecated.cpp
+++ cfe/trunk/test/SemaCXX/attr-deprecated.cpp
@@ -26,12 +26,12 @@
 }
 
 struct B {
-  virtual void f() __attribute__((deprecated)); // expected-note 4 {{'f' has been explicitly marked deprecated here}}
+  virtual void f() __attribute__((deprecated)); // expected-note 6 {{'f' has been explicitly marked deprecated here}}
   void g();
 };
 
 void B::g() {
-  f();
+  f(); // expected-warning{{'f' is deprecated}}
   B::f(); // expected-warning{{'f' is deprecated}}
 }
 
@@ -47,7 +47,7 @@
 }
 
 void f(B* b, C *c) {
-  b->f();
+  b->f(); // expected-warning{{'f' is deprecated}}
   b->B::f(); // expected-warning{{'f' is deprecated}}
   
   c->f();
@@ -59,10 +59,10 @@
   virtual void f() __attribute__((deprecated));
 };
 
-void D::f() { }
+void D::f() { } // expected-note{{'f' has been explicitly marked deprecated here}}
 
 void f(D* d) {
-  d->f();
+  d->f(); // expected-warning{{'f' is deprecated}}
 }
 
 
Index: cfe/trunk/test/SemaCXX/deleted-function-access.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/deleted-function-access.cpp
+++ cfe/trunk/test/SemaCXX/deleted-function-access.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+struct S {
+    virtual void f() = delete; //expected-note{{'f' has been explicitly marked deleted here}}
+    void g() { f(); } //expected-error{{attempt to use a deleted function}}
+};
Index: cfe/trunk/lib/Sema/SemaExprMember.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp
@@ -1042,16 +1042,8 @@
     BaseExpr = new (Context) CXXThisExpr(Loc, BaseExprType,/*isImplicit=*/true);
   }
 
-  bool ShouldCheckUse = true;
-  if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(MemberDecl)) {
-    // Don't diagnose the use of a virtual member function unless it's
-    // explicitly qualified.
-    if (MD->isVirtual() && !SS.isSet())
-      ShouldCheckUse = false;
-  }
-
   // Check the use of this member.
-  if (ShouldCheckUse && DiagnoseUseOfDecl(MemberDecl, MemberLoc))
+  if (DiagnoseUseOfDecl(MemberDecl, MemberLoc))
     return ExprError();
 
   if (FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11334.30302.patch
Type: text/x-patch
Size: 2397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150722/c3c21dc2/attachment.bin>


More information about the cfe-commits mailing list