From: Alexandre Oliva Date: Thu, 6 Dec 2018 23:18:30 +0000 (+0000) Subject: [PR86397] resolve nondependent noexcept specs early in C++1[14] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0d699def39bb937e3fddbd8149892594447b7f0d;p=gcc.git [PR86397] resolve nondependent noexcept specs early in C++1[14] 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. From-SVN: r266874 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 601ca78a147..727f2d4f909 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-12-06 Alexandre Oliva + + PR c++/86397 + * except.c (build_noexcept_spec): Resolve nondependent + expressions. + 2018-12-06 Jason Merrill PR c++/88136 - -Wdeprecated-copy false positives diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 7e39cdf68a9..ab1bd8267ff 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/ChangeLog b/gcc/testsuite/ChangeLog index 708c8c00887..eddb4576e0f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-12-06 Alexandre Oliva + + PR c++/86397 + * g++.dg/cpp0x/pr86397-1.C: New. + * g++.dg/cpp0x/pr86397-2.C: New. + 2018-12-06 Paul A. Clarke PR target/88316 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 00000000000..4f9f5fa7e4c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr86397-1.C @@ -0,0 +1,4 @@ +// { dg-do compile { target c++11 } } +void e(); +template void f(int() noexcept(e)) {} +template void f(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 00000000000..fb43499526e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr86397-2.C @@ -0,0 +1,4 @@ +// { dg-do compile { target c++11 } } +void e(); +template void f(int() noexcept(e)) {} +template void f(int() noexcept);