* pt.c (tsubst_expr) [DECL_EXPR]: Handle capture proxies properly.
* semantics.c (insert_capture_proxy): No longer static.
* cp-tree.h: Declare it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182141
138bc75d-0d04-0410-961f-
82ee72b054a4
+2011-12-08 Jason Merrill <jason@redhat.com>
+
+ PR c++/51459
+ * pt.c (tsubst_expr) [DECL_EXPR]: Handle capture proxies properly.
+ * semantics.c (insert_capture_proxy): No longer static.
+ * cp-tree.h: Declare it.
+
2011-12-07 Jakub Jelinek <jakub@redhat.com>
PR c++/51401
extern tree add_capture (tree, tree, tree, bool, bool);
extern tree add_default_capture (tree, tree, tree);
extern tree build_capture_proxy (tree);
+extern void insert_capture_proxy (tree);
extern void insert_pending_capture_proxies (void);
extern bool is_capture_proxy (tree);
extern bool is_normal_capture_proxy (tree);
&& ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
/* Anonymous aggregates are a special case. */
finish_anon_union (decl);
+ else if (is_capture_proxy (DECL_EXPR_DECL (t)))
+ {
+ DECL_CONTEXT (decl) = current_function_decl;
+ insert_capture_proxy (decl);
+ }
else
{
int const_init = false;
/* VAR is a capture proxy created by build_capture_proxy; add it to the
current function, which is the operator() for the appropriate lambda. */
-static inline void
+void
insert_capture_proxy (tree var)
{
cp_binding_level *b;
+2011-12-08 Jason Merrill <jason@redhat.com>
+
+ PR c++/51459
+ * g++.dg/cpp0x/lambda/lambda-template4.C: New.
+
2011-12-08 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/51466
--- /dev/null
+// PR c++/51459
+// { dg-do run { target c++11 } }
+
+struct func {
+ virtual ~func() { }
+ virtual void operator()() const = 0;
+ virtual func* clone() const = 0;
+};
+
+template<typename T>
+struct funcimpl : func {
+ explicit funcimpl(T t) : t(t) { }
+ void operator()() const { t(); }
+ func* clone() const { return new funcimpl(*this); }
+ T t;
+};
+
+struct function
+{
+ func* p;
+
+ template<typename T>
+ function(T t) : p(new funcimpl<T>(t)) { }
+
+ ~function() { delete p; }
+
+ function(const function& f) : p(f.p->clone()) { }
+
+ function& operator=(const function& ) = delete;
+
+ void operator()() const { (*p)(); }
+};
+
+template <typename F>
+function animate(F f) { return [=]{ f(); }; }
+
+int main()
+{
+ function linear1 = []{};
+ function av(animate(linear1));
+ av();
+}