]> granicus.if.org Git - clang/commitdiff
When there are any member new operators, global versions aren't looked up at all.
authorSebastian Redl <sebastian.redl@getdesigned.at>
Thu, 14 May 2009 18:11:41 +0000 (18:11 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Thu, 14 May 2009 18:11:41 +0000 (18:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71780 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/new-delete.cpp

index 57aae29631930b0efeca684d4a72e09999b02fa1..e2a21d9b3f380a3b4f0e889e0ced093a7bf814a8 100644 (file)
@@ -533,8 +533,6 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
   }
 
   case OR_No_Viable_Function:
-    if (AllowMissing)
-      return false;
     Diag(StartLoc, diag::err_ovl_no_viable_function_in_call)
       << Name << Range;
     PrintOverloadCandidates(Candidates, /*OnlyViable=*/false);
index 6fbf2c13862cd0b2c24d73b68ac948d0eb247fe8..2f763e0f78aaed612b410ab0382db3bdaf41253b 100644 (file)
@@ -12,7 +12,7 @@ struct T; // expected-note{{forward declaration of '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, S*); // expected-note {{candidate}}
 };
 struct V : U
 {
@@ -37,7 +37,7 @@ void good_news()
   ia4 *pai = new (int[3][4]);
   pi = ::new int;
   U *pu = new (ps) U;
-  // This is xfail. Inherited functions are not looked up currently.
+  // FIXME: Inherited functions are not looked up currently.
   //V *pv = new (ps) V;
 }
 
@@ -68,6 +68,8 @@ void bad_news(int *ip)
   (void)new (0L) int; // expected-error {{call to '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'}}
+  // This must fail, because any member version hides all global versions.
+  (void)new U; // expected-error {{no matching function for call to 'operator new'}}
   (void)new (int[]); // expected-error {{array size must be specified in new expressions}}
   (void)new int&; // expected-error {{cannot allocate reference type 'int &' with new}}
   // Some lacking cases due to lack of sema support.