[cfe-commits] r72129 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateExpr.cpp test/SemaTemplate/instantiate-expr-3.cpp
Douglas Gregor
dgregor at apple.com
Tue May 19 13:31:22 PDT 2009
Author: dgregor
Date: Tue May 19 15:31:21 2009
New Revision: 72129
URL: http://llvm.org/viewvc/llvm-project?rev=72129&view=rev
Log:
Template instantiation for GNU statement expressions
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=72129&r1=72128&r2=72129&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Tue May 19 15:31:21 2009
@@ -54,6 +54,8 @@
OwningExprResult VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
OwningExprResult VisitCXXConditionDeclExpr(CXXConditionDeclExpr *E);
OwningExprResult VisitConditionalOperator(ConditionalOperator *E);
+ // FIXME: AddrLabelExpr
+ OwningExprResult VisitStmtExpr(StmtExpr *E);
OwningExprResult VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
OwningExprResult VisitUnresolvedDeclRefExpr(UnresolvedDeclRefExpr *E);
OwningExprResult VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E);
@@ -453,6 +455,16 @@
move(Cond), move(LHS), move(RHS));
}
+Sema::OwningExprResult TemplateExprInstantiator::VisitStmtExpr(StmtExpr *E) {
+ Sema::OwningStmtResult SubStmt = SemaRef.InstantiateStmt(E->getSubStmt(),
+ TemplateArgs);
+ if (SubStmt.isInvalid())
+ return SemaRef.ExprError();
+
+ return SemaRef.ActOnStmtExpr(E->getLParenLoc(), move(SubStmt),
+ E->getRParenLoc());
+}
+
Sema::OwningExprResult
TemplateExprInstantiator::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
bool isSizeOf = E->isSizeOf();
Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp?rev=72129&r1=72128&r2=72129&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp Tue May 19 15:31:21 2009
@@ -56,3 +56,16 @@
};
template struct Conditional0<int, int, int>;
+
+// ---------------------------------------------------------------------
+// Statement expressions
+// ---------------------------------------------------------------------
+template<typename T>
+struct StatementExpr0 {
+ void f(T t) {
+ (void)({ if (t) t = t + 17; }); // expected-error{{invalid}}
+ }
+};
+
+template struct StatementExpr0<int>;
+template struct StatementExpr0<N1::X>; // expected-note{{instantiation}}
More information about the cfe-commits
mailing list