diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-12-04 17:24:46 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2008-12-04 17:24:46 +0000 |
commit | 636a7c42d42800f69caadcdea433312fd642a4b3 (patch) | |
tree | 6b8cc228d6931bb69b2ee5ff36853ca09aab9b9a | |
parent | c77a636688e188af7e7a9a05829e542adb48e880 (diff) |
Fix some diagnostics and enhance test cases. Now tests member new and ambiguous overloads.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60542 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 6 | ||||
-rw-r--r-- | test/SemaCXX/new-delete.cpp | 9 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 1cecb5dc70..72ca8df5e8 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -432,7 +432,8 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, bool UseGlobal, 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 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, bool UseGlobal, 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; } diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp index 89c33474bf..c90cd2f314 100644 --- a/test/SemaCXX/new-delete.cpp +++ b/test/SemaCXX/new-delete.cpp @@ -9,6 +9,11 @@ struct S // expected-note {{candidate}} 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 @@ void good_news() 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 bad_news(int *ip) (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. } |