From fc27d268cb34cbb8d186c6ad7cc043d41581ce71 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sun, 31 May 2009 19:49:47 +0000 Subject: [PATCH] Fix an off by one error when trying to perform copy initialization of operator new and operator delete arguments. Sebastian, please review. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72670 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 2 +- test/SemaCXX/new-delete.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 73cc0513f0..a44dcf6f8b 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -550,7 +550,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, // asserted on, though, since invalid decls are left in there.) for (unsigned i = 1; i < NumArgs; ++i) { // FIXME: Passing word to diagnostic. - if (PerformCopyInitialization(Args[i-1], + if (PerformCopyInitialization(Args[i], FnDecl->getParamDecl(i)->getType(), "passing")) return true; diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp index 2f763e0f78..f890bf56e3 100644 --- a/test/SemaCXX/new-delete.cpp +++ b/test/SemaCXX/new-delete.cpp @@ -21,6 +21,7 @@ struct V : U void* operator new(size_t); // expected-note 2 {{candidate}} void* operator new(size_t, int*); // expected-note 3 {{candidate}} void* operator new(size_t, float*); // expected-note 3 {{candidate}} +void* operator new(size_t, S); // expected-note 2 {{candidate}} void good_news() { @@ -39,6 +40,8 @@ void good_news() U *pu = new (ps) U; // FIXME: Inherited functions are not looked up currently. //V *pv = new (ps) V; + + pi = new (S(1.0f, 2)) int; } struct abstract { -- 2.40.0