forked from OSchip/llvm-project
Make sure to copy back arguments that can be changed by FindAllocationOverload. This fixes placement new. (Sebastian, please review).
llvm-svn: 72673
This commit is contained in:
parent
1832f52b10
commit
6f9dabff6d
|
@ -508,6 +508,11 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
|
|||
return true;
|
||||
}
|
||||
|
||||
// FindAllocationOverload can change the passed in arguments, so we need to
|
||||
// copy them back.
|
||||
if (NumPlaceArgs > 0)
|
||||
std::copy(&AllocArgs[1], AllocArgs.end(), PlaceArgs);
|
||||
|
||||
// FIXME: This is leaked on error. But so much is currently in Sema that it's
|
||||
// easier to clean it in one go.
|
||||
AllocArgs[0]->Destroy(Context);
|
||||
|
|
|
@ -3,3 +3,10 @@
|
|||
void t1() {
|
||||
int* a = new int;
|
||||
}
|
||||
|
||||
// Placement.
|
||||
void* operator new(unsigned long, void*) throw();
|
||||
|
||||
void t2(int* a) {
|
||||
int* b = new (a) int;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue