c++: ICE with noexcept and local specialization, again [PR114349]
commit8651991fe2ea90a7276e91673b15b5c3865f14d7
authorMarek Polacek <polacek@redhat.com>
Fri, 15 Mar 2024 13:23:28 +0000 (15 09:23 -0400)
committerMarek Polacek <polacek@redhat.com>
Mon, 25 Mar 2024 22:20:55 +0000 (25 18:20 -0400)
treeea04b3f801fc2a7b9cf97fb0b0bf58878dbf5e44
parentde0886d48032332d10e4acb5d15c8789b281b6fe
c++: ICE with noexcept and local specialization, again [PR114349]

Patrick noticed that my r14-9339-gdc6c3bfb59baab patch is wrong;
we're dealing with a noexcept-spec there, not a noexcept-expr, so
setting cp_noexcept_operand et al is incorrect.  Back to the drawing
board then.

To fix noexcept84.C, we should probably avoid doing push_to_top_level
in certain cases.  maybe_push_to_top_level didn't work here as-is, so
I changed it to not push to top level if decl_function_context is
non-null, when we are not dealing with a lambda.

This also fixes c++/114349, introduced by r14-9339.

PR c++/114349

gcc/cp/ChangeLog:

* name-lookup.cc (maybe_push_to_top_level): For a non-lambda,
don't push to top level if decl_function_context is non-null.
* pt.cc (maybe_instantiate_noexcept): Use maybe_push_to_top_level.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/noexcept85.C: New test.
* g++.dg/cpp0x/noexcept86.C: New test.
gcc/cp/name-lookup.cc
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp0x/noexcept85.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/noexcept86.C [new file with mode: 0644]