[cfe-commits] r88747 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaCXX/new-delete.cpp

Anders Carlsson andersca at mac.com
Fri Nov 13 19:17:38 PST 2009


Author: andersca
Date: Fri Nov 13 21:17:38 2009
New Revision: 88747

URL: http://llvm.org/viewvc/llvm-project?rev=88747&view=rev
Log:
Diagnose ambiguity of operator delete and operator delete[]. Sebastian, please review.

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/test/SemaCXX/new-delete.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=88747&r1=88746&r2=88747&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Nov 13 21:17:38 2009
@@ -851,8 +851,13 @@
       // Try to find operator delete/operator delete[] in class scope.
       LookupResult Found;
       LookupQualifiedName(Found, Record, DeleteName, LookupOrdinaryName);
+      
+      if (Found.isAmbiguous()) {
+        DiagnoseAmbiguousLookup(Found, DeleteName, StartLoc);
+        return ExprError();
+      }
+      
       // FIXME: Diagnose ambiguity properly
-      assert(!Found.isAmbiguous() && "Ambiguous delete/delete[] not handled");
       for (LookupResult::iterator F = Found.begin(), FEnd = Found.end();
            F != FEnd; ++F) {
         if (CXXMethodDecl *Delete = dyn_cast<CXXMethodDecl>(*F))

Modified: cfe/trunk/test/SemaCXX/new-delete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/new-delete.cpp?rev=88747&r1=88746&r2=88747&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/new-delete.cpp (original)
+++ cfe/trunk/test/SemaCXX/new-delete.cpp Fri Nov 13 21:17:38 2009
@@ -165,3 +165,20 @@
 
 TBase<int> t1; // expected-note {{in instantiation of template class 'struct TBase<int>' requested here}}
 
+class X6 {
+public:
+  static void operator delete(void*, int); // expected-note {{member found by ambiguous name lookup}}
+};
+
+class X7 {
+public:
+  static void operator delete(void*, int); // expected-note {{member found by ambiguous name lookup}}
+};
+
+class X8 : public X6, public X7 {
+};
+
+void f(X8* x8) {
+  delete x8; // expected-error {{member 'operator delete' found in multiple base classes of different types}}
+}
+





More information about the cfe-commits mailing list