From cc6fe784486b77d96bd4cb9cb1d6556c1d5480fb Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 29 Nov 2017 21:54:18 +0000 Subject: [PATCH] re PR c++/82293 (ICE in nonlambda_method_basetype at gcc/cp/lambda.c:886) /cp 2017-11-29 Paolo Carlini PR c++/82293 * lambda.c (nonlambda_method_basetype): Don't use LAMBDA_TYPE_P on a null type. /testsuite 2017-11-29 Paolo Carlini PR c++/82293 * g++.dg/cpp0x/lambda/lambda-ice24.C: New. From-SVN: r255254 --- gcc/cp/ChangeLog | 8 +++++++- gcc/cp/lambda.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice24.C | 12 ++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice24.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1bc460002dd..f9fdf1b91d4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-11-29 Paolo Carlini + + PR c++/82293 + * lambda.c (nonlambda_method_basetype): Don't use LAMBDA_TYPE_P + on a null type. + 2017-11-29 Jason Merrill PR c++/82760 - memory corruption with aligned new. @@ -12,7 +18,7 @@ (note_break_stmt, note_iteration_stmt_body_start, note_iteration_stmt_body_end): Declare. * decl.c (struct cp_switch): Add has_default_p, break_stmt_seen_p - and in_loop_body_p fields. + and in_loop_body_p fields. (push_switch): Clear them. (pop_switch): Set SWITCH_STMT_CANNOT_FALLTHRU_P if has_default_p and !break_stmt_seen_p. Assert in_loop_body_p is false. diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 8b8c1274bc6..c06f4415ebd 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -920,7 +920,7 @@ nonlambda_method_basetype (void) return NULL_TREE; type = current_class_type; - if (!LAMBDA_TYPE_P (type)) + if (!type || !LAMBDA_TYPE_P (type)) return type; /* Find the nearest enclosing non-lambda function. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2fc4c07585..f65c3d916b6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-11-29 Paolo Carlini + + PR c++/82293 + * g++.dg/cpp0x/lambda/lambda-ice24.C: New. + 2017-11-29 Will Schmidt * gcc.target/powerpc/fold-vec-ld-char.c: Add lxv to expected output. diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice24.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice24.C new file mode 100644 index 00000000000..2f42d714521 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice24.C @@ -0,0 +1,12 @@ +// PR c++/82293 +// { dg-do compile { target c++11 } } +// { dg-options "-Wshadow" } + +template +struct S { + int f{[this](){return 42;}()}; +}; + +int main(){ + return S{}.f; +} -- 2.30.2