Commit 0d699def by Alexandre Oliva Committed by Alexandre Oliva

[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
parent 695be092
2018-12-06 Alexandre Oliva <aoliva@redhat.com>
PR c++/86397
* except.c (build_noexcept_spec): Resolve nondependent
expressions.
2018-12-06 Jason Merrill <jason@redhat.com>
PR c++/88136 - -Wdeprecated-copy false positives
......
......@@ -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,
......
2018-12-06 Alexandre Oliva <aoliva@redhat.com>
PR c++/86397
* g++.dg/cpp0x/pr86397-1.C: New.
* g++.dg/cpp0x/pr86397-2.C: New.
2018-12-06 Paul A. Clarke <pc@us.ibm.com>
PR target/88316
......
// { 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 } }
// { dg-do compile { target c++11 } }
void e();
template <bool> void f(int() noexcept(e)) {}
template void f<false>(int() noexcept);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment