[cfe-commits] r123349 - in /cfe/trunk: lib/Sema/TreeTransform.h test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp
Douglas Gregor
dgregor at apple.com
Wed Jan 12 16:19:55 PST 2011
Author: dgregor
Date: Wed Jan 12 18:19:55 2011
New Revision: 123349
URL: http://llvm.org/viewvc/llvm-project?rev=123349&view=rev
Log:
Allow us to transform pack expansion expressions.
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=123349&r1=123348&r2=123349&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Jan 12 18:19:55 2011
@@ -6787,8 +6787,14 @@
template<typename Derived>
ExprResult
TreeTransform<Derived>::TransformPackExpansionExpr(PackExpansionExpr *E) {
- llvm_unreachable("pack expansion expression in unhandled context");
- return ExprError();
+ ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
+ if (Pattern.isInvalid())
+ return ExprError();
+
+ if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
+ return SemaRef.Owned(E);
+
+ return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc());
}
template<typename Derived>
Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp?rev=123349&r1=123348&r2=123349&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp Wed Jan 12 18:19:55 2011
@@ -56,4 +56,20 @@
X<int(float, double)> xif;
+ template<unsigned> struct unsigned_c { };
+ template<typename ...ArgTypes> int g(ArgTypes...);
+
+ template<typename F> struct X1;
+
+ template<typename R, typename ...ArgTypes>
+ struct X1<R(ArgTypes...)> {
+ unsigned_c<sizeof(1 + g(ArgTypes()...))> f();
+ };
+
+ template<typename R, typename ...ArgTypes>
+ unsigned_c<sizeof(1 + g(ArgTypes()...))> X1<R(ArgTypes...)>::f() {
+ return unsigned_c<sizeof(int)>();
+ }
+
+ X1<int(float, double)> xif2;
}
More information about the cfe-commits
mailing list