[cfe-commits] r72216 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateExpr.cpp test/SemaTemplate/instantiate-expr-4.cpp
Douglas Gregor
dgregor at apple.com
Thu May 21 10:21:16 PDT 2009
Author: dgregor
Date: Thu May 21 12:21:12 2009
New Revision: 72216
URL: http://llvm.org/viewvc/llvm-project?rev=72216&view=rev
Log:
Template instantiation for C++ delete expression
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=72216&r1=72215&r2=72216&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Thu May 21 12:21:12 2009
@@ -89,7 +89,7 @@
OwningExprResult VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E);
OwningExprResult VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E);
OwningExprResult VisitCXXNewExpr(CXXNewExpr *E);
- // FIXME: CXXDeleteExpr
+ OwningExprResult VisitCXXDeleteExpr(CXXDeleteExpr *E);
// FIXME: UnaryTypeTraitExpr
// FIXME: QualifiedDeclRefExpr
OwningExprResult VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
@@ -936,6 +936,18 @@
}
Sema::OwningExprResult
+TemplateExprInstantiator::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
+ OwningExprResult Operand = Visit(E->getArgument());
+ if (Operand.isInvalid())
+ return SemaRef.ExprError();
+
+ return SemaRef.ActOnCXXDelete(E->getSourceRange().getBegin(),
+ E->isGlobalDelete(),
+ E->isArrayForm(),
+ move(Operand));
+}
+
+Sema::OwningExprResult
TemplateExprInstantiator::VisitCXXExprWithTemporaries(
CXXExprWithTemporaries *E) {
OwningExprResult SubExpr = Visit(E->getSubExpr());
Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp?rev=72216&r1=72215&r2=72216&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp Thu May 21 12:21:12 2009
@@ -44,7 +44,7 @@
template struct Temporaries0<5, 7>;
// ---------------------------------------------------------------------
-// new expressions
+// new/delete expressions
// ---------------------------------------------------------------------
struct Y { };
@@ -83,3 +83,15 @@
template struct New2<X, int, float>;
template struct New2<X, int, int*>; // expected-note{{instantiation}}
// FIXME: template struct New2<int, int, float>;
+
+template<typename T>
+struct Delete0 {
+ void f(T t) {
+ delete t; // expected-error{{cannot delete}}
+ ::delete [] t;
+ }
+};
+
+template struct Delete0<int*>;
+template struct Delete0<X*>;
+template struct Delete0<int>; // expected-note{{instantiation}}
More information about the cfe-commits
mailing list