Fix some diagnostics and enhance test cases. Now tests member new and ambiguous overloads.

llvm-svn: 60542
This commit is contained in:
Sebastian Redl 2008-12-04 17:24:46 +00:00
parent 187250bd94
commit f84512a360
2 changed files with 13 additions and 2 deletions

View File

@ -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;
}

View File

@ -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.
}