[cfe-commits] r71822 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateExpr.cpp test/SemaTemplate/instantiate-function-1.cpp
Anders Carlsson
andersca at mac.com
Thu May 14 17:15:31 PDT 2009
Author: andersca
Date: Thu May 14 19:15:26 2009
New Revision: 71822
URL: http://llvm.org/viewvc/llvm-project?rev=71822&view=rev
Log:
Instantiate goto and label statements. (Very useful, I know)
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.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=71822&r1=71821&r2=71822&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Thu May 14 19:15:26 2009
@@ -445,6 +445,8 @@
OwningStmtResult VisitNullStmt(NullStmt *S);
OwningStmtResult VisitCompoundStmt(CompoundStmt *S);
OwningStmtResult VisitExpr(Expr *E);
+ OwningStmtResult VisitLabelStmt(LabelStmt *S);
+ OwningStmtResult VisitGotoStmt(GotoStmt *S);
// Base case. I'm supposed to ignore this.
OwningStmtResult VisitStmt(Stmt *S) {
@@ -481,6 +483,22 @@
return SemaRef.Owned(new (SemaRef.Context) NullStmt(S->getSemiLoc()));
}
+Sema::OwningStmtResult TemplateStmtInstantiator::VisitLabelStmt(LabelStmt *S) {
+ OwningStmtResult SubStmt = Visit(S->getSubStmt());
+
+ if (SubStmt.isInvalid())
+ return SemaRef.StmtError();
+
+ // FIXME: Pass the real colon loc in.
+ return SemaRef.ActOnLabelStmt(S->getIdentLoc(), S->getID(), SourceLocation(),
+ move(SubStmt));
+}
+
+Sema::OwningStmtResult TemplateStmtInstantiator::VisitGotoStmt(GotoStmt *S) {
+ return SemaRef.ActOnGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
+ S->getLabel()->getID());
+}
+
Sema::OwningStmtResult
TemplateStmtInstantiator::VisitCompoundStmt(CompoundStmt *S) {
// FIXME: We need an *easy* RAII way to delete these statements if
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=71822&r1=71821&r2=71822&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp Thu May 14 19:15:26 2009
@@ -26,3 +26,14 @@
template struct X2<int>;
template struct X2<int&>; // expected-note{{instantiation of}}
+
+template<typename T>
+struct X3 {
+ void f(T) {
+ Label:
+ T x;
+ goto Label;
+ }
+};
+
+template struct X3<int>;
More information about the cfe-commits
mailing list