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

Sebastian Redl sebastian.redl at getdesigned.at
Thu Dec 4 09:24:46 PST 2008


Author: cornedbee
Date: Thu Dec  4 11:24:46 2008
New Revision: 60542

URL: http://llvm.org/viewvc/llvm-project?rev=60542&view=rev
Log:
Fix some diagnostics and enhance test cases. Now tests member new and ambiguous overloads.

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=60542&r1=60541&r2=60542&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Dec  4 11:24:46 2008
@@ -432,7 +432,8 @@
 
     case OR_Ambiguous:
       // FIXME: Bad location information.
-      Diag(StartLoc, diag::err_ovl_ambiguous_oper) << NewName;
+      Diag(StartLoc, diag::err_ovl_ambiguous_oper)
+        << (IsArray ? "new[]" : "new");
       PrintOverloadCandidates(MemberNewCandidates, /*OnlyViable=*/true);
       return true;
     }
@@ -491,7 +492,8 @@
 
     case OR_Ambiguous:
       // FIXME: Bad location information.
-      Diag(StartLoc, diag::err_ovl_ambiguous_oper) << NewName;
+      Diag(StartLoc, diag::err_ovl_ambiguous_oper)
+        << (IsArray ? "new[]" : "new");
       PrintOverloadCandidates(GlobalNewCandidates, /*OnlyViable=*/true);
       return true;
     }

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

==============================================================================
--- cfe/trunk/test/SemaCXX/new-delete.cpp (original)
+++ cfe/trunk/test/SemaCXX/new-delete.cpp Thu Dec  4 11:24:46 2008
@@ -9,6 +9,11 @@
   S(float, int); // expected-note {{candidate}} expected-note {{candidate}}
 };
 struct T;
+struct U
+{
+  // A special new, to verify that the global version isn't used.
+  void* operator new(size_t, S*);
+};
 
 void* operator new(size_t); // expected-note {{candidate}}
 void* operator new(size_t, int*); // expected-note {{candidate}}
@@ -28,6 +33,7 @@
   typedef int ia4[4];
   ia4 *pai = new (int[3][4]);
   pi = ::new int;
+  U *pu = new (ps) U;
 }
 
 void bad_news(int *ip)
@@ -50,6 +56,9 @@
   (void)new int[*(S*)0]; // expected-error {{array size expression must have integral or enumerated type, not 'struct S'}}
   (void)::S::new int; // expected-error {{expected unqualified-id}}
   (void)new (0, 0) int; // expected-error {{no matching function for call to 'operator new'}}
+  (void)new (0L) int; // expected-error {{use of overloaded operator 'new' is ambiguous}}
+  // This must fail, because the member version shouldn't be found.
+  (void)::new ((S*)0) U; // expected-error {{no matching function for call to 'operator new'}}
   // Some lacking cases due to lack of sema support.
 }
 





More information about the cfe-commits mailing list