diff options
author | Jason Merrill <jason@redhat.com> | 2014-05-13 13:54:00 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-05-13 13:54:00 -0400 |
commit | 6626c52e1a6af7b32200ec1bf22fc790e5717480 (patch) | |
tree | a71adf45048e5da014158f460fbf411075e369fe /gcc | |
parent | 2b107f6b91d1b44ec60bd5ce8b51218a84aac98a (diff) | |
download | gcc-6626c52e1a6af7b32200ec1bf22fc790e5717480.zip gcc-6626c52e1a6af7b32200ec1bf22fc790e5717480.tar.gz gcc-6626c52e1a6af7b32200ec1bf22fc790e5717480.tar.bz2 |
re PR c++/61151 (ICE with lambda)
PR c++/61151
* semantics.c (is_this_parameter): Allow capture proxies too.
From-SVN: r210394
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this18.C | 30 |
3 files changed, 39 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ca07527..a26472c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2014-05-13 Jason Merrill <jason@redhat.com> + + PR c++/61151 + * semantics.c (is_this_parameter): Allow capture proxies too. + 2014-05-12 Jason Merrill <jason@redhat.com> * call.c (maybe_print_user_conv_context): New. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d925f5c..583b870 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8158,8 +8158,10 @@ maybe_initialize_constexpr_call_table (void) bool is_this_parameter (tree t) { - return (TREE_CODE (t) == PARM_DECL - && DECL_NAME (t) == this_identifier); + if (!DECL_P (t) || DECL_NAME (t) != this_identifier) + return false; + gcc_assert (TREE_CODE (t) == PARM_DECL || is_capture_proxy (t)); + return true; } /* We have an expression tree T that represents a call, either CALL_EXPR diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this18.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this18.C new file mode 100644 index 0000000..fec2da6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this18.C @@ -0,0 +1,30 @@ +// PR c++/61151 +// { dg-do compile { target c++11 } } + +struct B +{ + void foo () {} +}; + +template <class> +struct A +{ + template <class> void bar (); + B a; +}; + +template <class T> +template <class U> +void +A<T>::bar () +{ + auto f = [this] () { auto g = [=] () { a.foo (); }; g (); }; + f (); +} + +int +main () +{ + A<int> a; + a.bar <int> (); +} |