[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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266874 138bc75d-0d04-0410-961f-82ee72b054a4
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 601ca78a..727f2d4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index 7e39cdf..ab1bd82 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -1189,11 +1189,8 @@
 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 708c8c0..eddb457 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..4f9f5fa
--- /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 0000000..fb43499
--- /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);