[PR86397] resolve nondependent noexcept specs early in C++1[14]
authorAlexandre Oliva <aoliva@redhat.com>
Thu, 6 Dec 2018 23:18:30 +0000 (23:18 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Thu, 6 Dec 2018 23:18:30 +0000 (23:18 +0000)
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

gcc/cp/ChangeLog
gcc/cp/except.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr86397-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr86397-2.C [new file with mode: 0644]

index 601ca78a147ce01b53781eb372619151c147ac9e..727f2d4f909f2cdd7207e044bef3477fdb7ff452 100644 (file)
@@ -1,3 +1,9 @@
+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
index 7e39cdf68a9c03eb581243bb73b3f6686efc16a3..ab1bd8267ff6ac8f8c1658f9254d7ce1a6bbf5d9 100644 (file)
@@ -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,
index 708c8c00887099382938bcc7bf3b5b6a39aec494..eddb4576e0fde25fd5af1d60cf5e2b6c66b16f82 100644 (file)
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr86397-1.C b/gcc/testsuite/g++.dg/cpp0x/pr86397-1.C
new file mode 100644 (file)
index 0000000..4f9f5fa
--- /dev/null
@@ -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 (file)
index 0000000..fb43499
--- /dev/null
@@ -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);