summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-10-17 21:40:42 +0000
committerDouglas Gregor <dgregor@apple.com>2009-10-17 21:40:42 +0000
commit4bbd1acf8b9bfa849470b3bafaaf6e966fe51078 (patch)
treec792f0ef1e3948657077e00551db5dca1b98f038
parent965fe98af630f95f3ab2a4057dda915157c0b81c (diff)
downloadbcm5719-llvm-4bbd1acf8b9bfa849470b3bafaaf6e966fe51078.tar.gz
bcm5719-llvm-4bbd1acf8b9bfa849470b3bafaaf6e966fe51078.zip
When type-checking a C++ "new" expression, don't type-check the actual
initialization if any of the constructor/initialization arguments are type-dependent. Fixes PR5224. llvm-svn: 84365
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp7
-rw-r--r--clang/test/SemaTemplate/fun-template-def.cpp2
-rw-r--r--clang/test/SemaTemplate/instantiate-expr-2.cpp15
3 files changed, 21 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d56c426d00a..b6dcd76d462 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -418,6 +418,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
FunctionDecl *OperatorDelete = 0;
Expr **PlaceArgs = (Expr**)PlacementArgs.get();
unsigned NumPlaceArgs = PlacementArgs.size();
+
if (!AllocType->isDependentType() &&
!Expr::hasAnyTypeDependentArguments(PlaceArgs, NumPlaceArgs) &&
FindAllocationFunctions(StartLoc,
@@ -448,7 +449,9 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
Expr **ConsArgs = (Expr**)ConstructorArgs.get();
const RecordType *RT;
unsigned NumConsArgs = ConstructorArgs.size();
- if (AllocType->isDependentType()) {
+
+ if (AllocType->isDependentType() ||
+ Expr::hasAnyTypeDependentArguments(ConsArgs, NumConsArgs)) {
// Skip all the checks.
} else if ((RT = AllocType->getAs<RecordType>()) &&
!AllocType->isAggregateType()) {
@@ -491,7 +494,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
}
// FIXME: Also check that the destructor is accessible. (C++ 5.3.4p16)
-
+
PlacementArgs.release();
ConstructorArgs.release();
ArraySizeE.release();
diff --git a/clang/test/SemaTemplate/fun-template-def.cpp b/clang/test/SemaTemplate/fun-template-def.cpp
index dee42500789..4d8aaa8d16f 100644
--- a/clang/test/SemaTemplate/fun-template-def.cpp
+++ b/clang/test/SemaTemplate/fun-template-def.cpp
@@ -35,7 +35,7 @@ T f1(T t1, U u1, int i1)
dynamic_cast<U>(const_cast<T>(i1)))));
new U(i1, t1);
- new int(t1, u1); // expected-error {{initializer of a builtin type can only take one argument}}
+ new int(t1, u1);
new (t1, u1) int;
delete t1;
diff --git a/clang/test/SemaTemplate/instantiate-expr-2.cpp b/clang/test/SemaTemplate/instantiate-expr-2.cpp
index 146e63c5bb0..194593ac400 100644
--- a/clang/test/SemaTemplate/instantiate-expr-2.cpp
+++ b/clang/test/SemaTemplate/instantiate-expr-2.cpp
@@ -178,3 +178,18 @@ namespace N10 {
template class A<int>;
}
+
+namespace N12 {
+ // PR5224
+ template<typename T>
+ struct A { typedef int t0; };
+
+ struct C {
+ C(int);
+
+ template<typename T>
+ static C *f0(T a0) {return new C((typename A<T>::t0) 1); }
+ };
+
+ void f0(int **a) { C::f0(a); }
+}
OpenPOWER on IntegriCloud