diff options
author | Anders Carlsson <andersca@mac.com> | 2010-05-16 16:24:20 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-05-16 16:24:20 +0000 |
commit | 55cbd6e51fdca832c31bf8c179c40978a5d1f892 (patch) | |
tree | 2f4d5361ee828c6e3e81ca1a12607ac636b13be1 | |
parent | 3caf04ea0c01ff6822209c4621c3fa64a48029a4 (diff) |
Correctly diagnose array 'new' with initialization arguments when the new type is a typedef to an array type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103909 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/new-delete.cpp | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 01da9c1c8f..f337a429ca 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -760,7 +760,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, ASTOwningVector<&ActionBase::DeleteExpr> ConvertedConstructorArgs(*this); // Array 'new' can't have any initializers. - if (NumConsArgs && ArraySize) { + if (NumConsArgs && (ResultType->isArrayType() || ArraySize)) { SourceRange InitRange(ConsArgs[0]->getLocStart(), ConsArgs[NumConsArgs - 1]->getLocEnd()); diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp index 7b9b9d497f..8c9719b750 100644 --- a/test/SemaCXX/new-delete.cpp +++ b/test/SemaCXX/new-delete.cpp @@ -245,6 +245,9 @@ namespace Test1 { void f() { (void)new int[10](1, 2); // expected-error {{array 'new' cannot have initialization arguments}} + + typedef int T[10]; + (void)new T(1, 2); // expected-error {{array 'new' cannot have initialization arguments}} } template<typename T> |