From: Jason Merrill Date: Fri, 19 Jun 2015 18:15:24 +0000 (-0400) Subject: re PR c++/65843 (multiple use of const variable in lamba in template function causes... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=892562cf28252bd284a4cd4d249f20c1755a6b5b;p=gcc.git re PR c++/65843 (multiple use of const variable in lamba in template function causes compile error) PR c++/65843 * pt.c (tsubst_copy_and_build): Register a capture proxy in local_specializations. From-SVN: r224676 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index eb8d97ab1e8..4f2d4a6e27b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-06-19 Jason Merrill + + PR c++/65843 + * pt.c (tsubst_copy_and_build): Register a capture proxy in + local_specializations. + 2015-06-17 Jason Merrill PR c++/66001 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ccce90dba95..5dd5bfe55de 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15665,7 +15665,11 @@ tsubst_copy_and_build (tree t, r = build_cxx_call (wrap, 0, NULL, tf_warning_or_error); } else if (outer_automatic_var_p (r)) - r = process_outer_var_ref (r, complain); + { + r = process_outer_var_ref (r, complain); + if (is_capture_proxy (r)) + register_local_specialization (r, t); + } if (TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE) /* If the original type was a reference, we'll be wrapped in diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-rep1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-rep1.C new file mode 100644 index 00000000000..a35060b0a52 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-rep1.C @@ -0,0 +1,14 @@ +// PR c++/65843 +// { dg-do compile { target c++11 } } + +template +void test(T b) +{ + const int a = b; + [&] () { return a, a; }(); +} + +int main() { + test(1); + return 0; +}