[cfe-commits] r72185 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateExpr.cpp test/SemaTemplate/instantiate-expr-4.cpp test/SemaTemplate/instantiate-function-1.cpp
Douglas Gregor
dgregor at apple.com
Wed May 20 14:51:02 PDT 2009
Author: dgregor
Date: Wed May 20 16:51:01 2009
New Revision: 72185
URL: http://llvm.org/viewvc/llvm-project?rev=72185&view=rev
Log:
Template instantiation for CXXExprWithTemporaries, which occurs when
temporaries are generated for some object-constructing expressions in
templates that are not type-dependent.
Also, be sure to introduce the variable from a CXXConditionDeclExpr
into the set of instantiated local variables.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=72185&r1=72184&r2=72185&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Wed May 20 16:51:01 2009
@@ -92,7 +92,7 @@
// FIXME: CXXDeleteExpr
// FIXME: UnaryTypeTraitExpr
// FIXME: QualifiedDeclRefExpr
- // FIXME: CXXExprWithTemporaries
+ OwningExprResult VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
OwningExprResult VisitCXXUnresolvedConstructExpr(
CXXUnresolvedConstructExpr *E);
OwningExprResult VisitGNUNullExpr(GNUNullExpr *E);
@@ -450,6 +450,7 @@
if (!Var)
return SemaRef.ExprError();
+ SemaRef.CurrentInstantiationScope->InstantiatedLocal(E->getVarDecl(), Var);
return SemaRef.Owned(new (SemaRef.Context) CXXConditionDeclExpr(
E->getStartLoc(),
SourceLocation(),
@@ -877,6 +878,7 @@
return SemaRef.ExprError();
}
+ SemaRef.CurrentInstantiationScope->InstantiatedLocal(E->getVarDecl(), Var);
return SemaRef.Owned(CXXConstructExpr::Create(SemaRef.Context, Var, T,
E->getConstructor(),
E->isElidable(),
@@ -917,6 +919,16 @@
}
Sema::OwningExprResult
+TemplateExprInstantiator::VisitCXXExprWithTemporaries(
+ CXXExprWithTemporaries *E) {
+ OwningExprResult SubExpr = Visit(E->getSubExpr());
+ if (SubExpr.isInvalid())
+ return SemaRef.ExprError();
+
+ return SemaRef.ActOnFinishFullExpr(move(SubExpr));
+}
+
+Sema::OwningExprResult
TemplateExprInstantiator::VisitCXXUnresolvedConstructExpr(
CXXUnresolvedConstructExpr *E) {
QualType T = SemaRef.InstantiateType(E->getTypeAsWritten(), TemplateArgs,
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=72185&r1=72184&r2=72185&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp Wed May 20 16:51:01 2009
@@ -33,3 +33,12 @@
};
template struct BuildTemporary0<5, 7>;
+
+template<int N, int M>
+struct Temporaries0 {
+ void f() {
+ (void)X(N, M);
+ }
+};
+
+template struct Temporaries0<5, 7>;
Modified: cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp?rev=72185&r1=72184&r2=72185&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp Wed May 20 16:51:01 2009
@@ -69,6 +69,9 @@
return v; // expected-error{{incompatible type}}
}
+ if (T x = t) {
+ t = x;
+ }
return v;
}
};
More information about the cfe-commits
mailing list