Correctly diagnose array 'new' with initialization arguments when the new type is a typedef to an array type.

llvm-svn: 103909
This commit is contained in:
Anders Carlsson 2010-05-16 16:24:20 +00:00
parent cda95f47e5
commit e6ae81b0a2
2 changed files with 4 additions and 1 deletions

View File

@ -760,7 +760,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
ASTOwningVector<&ActionBase::DeleteExpr> ConvertedConstructorArgs(*this); ASTOwningVector<&ActionBase::DeleteExpr> ConvertedConstructorArgs(*this);
// Array 'new' can't have any initializers. // Array 'new' can't have any initializers.
if (NumConsArgs && ArraySize) { if (NumConsArgs && (ResultType->isArrayType() || ArraySize)) {
SourceRange InitRange(ConsArgs[0]->getLocStart(), SourceRange InitRange(ConsArgs[0]->getLocStart(),
ConsArgs[NumConsArgs - 1]->getLocEnd()); ConsArgs[NumConsArgs - 1]->getLocEnd());

View File

@ -245,6 +245,9 @@ namespace Test1 {
void f() { void f() {
(void)new int[10](1, 2); // expected-error {{array 'new' cannot have initialization arguments}} (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> template<typename T>