From: Jakub Jelinek Date: Mon, 11 Nov 2019 21:31:29 +0000 (+0100) Subject: re PR c++/92447 (ICE in poplevel, at cp/decl.c:585) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=48042bd43e0b0407748a110ef8e917827f0fe422;p=gcc.git re PR c++/92447 (ICE in poplevel, at cp/decl.c:585) PR c++/92447 * decl.c (finish_function): Move ctype initialization before DECL_DELETED_FN handling. * g++.dg/cpp0x/pr92447.C: New test. From-SVN: r278068 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 81811a41a38..a5bc9d452ce 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2019-11-11 Jakub Jelinek + PR c++/92447 + * decl.c (finish_function): Move ctype initialization before + DECL_DELETED_FN handling. + * semantics.c (finish_translation_unit): Diagnose declare target without corresponding end declare target. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5c5a85e3221..caa04afe805 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -16803,6 +16803,10 @@ finish_function (bool inline_p) } } + /* Remember that we were in class scope. */ + if (current_class_name) + ctype = current_class_type; + if (DECL_DELETED_FN (fndecl)) { DECL_INITIAL (fndecl) = error_mark_node; @@ -16861,10 +16865,6 @@ finish_function (bool inline_p) current_function_return_value = NULL_TREE; } - /* Remember that we were in class scope. */ - if (current_class_name) - ctype = current_class_type; - /* Must mark the RESULT_DECL as being in this function. */ DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 138afb2d5a9..872495bbae7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-11-11 Jakub Jelinek + PR c++/92447 + * g++.dg/cpp0x/pr92447.C: New test. + * c-c++-common/gomp/declare-target-5.c: New test. 2019-11-11 Richard Sandiford diff --git a/gcc/testsuite/g++.dg/cpp0x/pr92447.C b/gcc/testsuite/g++.dg/cpp0x/pr92447.C new file mode 100644 index 00000000000..f332e80e4f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr92447.C @@ -0,0 +1,14 @@ +// PR c++/92447 +// { dg-do compile { target c++11 } } + +template +void +foo () +{ + struct S { S &operator=(S &&x) = default; const T s{}; }; +} + +void bar () +{ + foo(); +}