On Nov 29, 2018, Jason Merrill <ja...@redhat.com> wrote: > Let's go with this. And remove the comment.
> And the !processing_template_decl is also redundant, since that's > checked at the top of value_dependent_expression_p. I've tested this on i686- and x86_64-linux-gnu. Ok to install? [PR86397] resolve nondependent noexcept specs early in C++1[14] From: Alexandre Oliva <aol...@redhat.com> build_noexcept_spec refrained from resolving nondependent noexcept expressions when they were not part of the function types (C++ 11 and 14). This caused problems during mangling: canonical_eh_spec, when called on the template function type, would find an unresolved but not explicitly deferred expression, and nothrow_spec_p would reject it. We could relax the mangling logic to skip canonical_eh_spec, but since -Wnoexcept-type warns when mangling function names that change as noexcept specs become part of types and of mangling in C++17, and the test at mangling time may give incorrect results if the spec is not resolved, we might as well keep things simple and resolve nondependent noexcept specs sooner rather than later. This is what this patch does. for gcc/cp/ChangeLog PR c++/86397 * except.c (build_noexcept_spec): Resolve nondependent expressions. for gcc/testsuite/ChangeLog PR c++/86397 * g++.dg/cpp0x/pr86397-1.C: New. * g++.dg/cpp0x/pr86397-2.C: New. --- gcc/cp/except.c | 5 +---- gcc/testsuite/g++.dg/cpp0x/pr86397-1.C | 4 ++++ gcc/testsuite/g++.dg/cpp0x/pr86397-2.C | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr86397-1.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr86397-2.C diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 3449b59b3cc0..a6951baa35c6 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -1189,11 +1189,8 @@ type_throw_all_p (const_tree type) tree build_noexcept_spec (tree expr, tsubst_flags_t complain) { - /* This isn't part of the signature, so don't bother trying to evaluate - it until instantiation. */ if (TREE_CODE (expr) != DEFERRED_NOEXCEPT - && (!processing_template_decl - || (flag_noexcept_type && !value_dependent_expression_p (expr)))) + && !value_dependent_expression_p (expr)) { expr = perform_implicit_conversion_flags (boolean_type_node, expr, complain, diff --git a/gcc/testsuite/g++.dg/cpp0x/pr86397-1.C b/gcc/testsuite/g++.dg/cpp0x/pr86397-1.C new file mode 100644 index 000000000000..4f9f5fa7e4c8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr86397-1.C @@ -0,0 +1,4 @@ +// { dg-do compile { target c++11 } } +void e(); +template <bool> void f(int() noexcept(e)) {} +template void f<false>(int()); // { dg-error "does not match" "" { target c++17 } } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr86397-2.C b/gcc/testsuite/g++.dg/cpp0x/pr86397-2.C new file mode 100644 index 000000000000..fb43499526e8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr86397-2.C @@ -0,0 +1,4 @@ +// { dg-do compile { target c++11 } } +void e(); +template <bool> void f(int() noexcept(e)) {} +template void f<false>(int() noexcept); -- Alexandre Oliva, freedom fighter https://FSFLA.org/blogs/lxo Be the change, be Free! FSF Latin America board member GNU Toolchain Engineer Free Software Evangelist Hay que enGNUrecerse, pero sin perder la terGNUra jamás-GNUChe