If we're going to consider the noexcept-specifier for deduction, we
also need it to make the type dependent.

Tested x86_64-pc-linux-gnu, applying to trunk and 7.
commit c51759f129a602eeb835473e7c1480046757c12f
Author: Jason Merrill <ja...@redhat.com>
Date:   Wed May 31 17:39:50 2017 -0400

            PR c++/80384 - ICE with dependent noexcept-specifier
    
            * pt.c (dependent_type_p_r) [FUNCTION_TYPE]: Check for dependent
            noexcept-specifier.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 48fa9b8..a72c314 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -23438,6 +23438,14 @@ dependent_type_p_r (tree type)
           arg_type = TREE_CHAIN (arg_type))
        if (dependent_type_p (TREE_VALUE (arg_type)))
          return true;
+      if (cxx_dialect >= cxx1z)
+       {
+         /* A value-dependent noexcept-specifier makes the type dependent.  */
+         tree spec = TYPE_RAISES_EXCEPTIONS (type);
+         if (spec && TREE_PURPOSE (spec)
+             && value_dependent_expression_p (TREE_PURPOSE (spec)))
+           return true;
+       }
       return false;
     }
   /* -- an array type constructed from any dependent type or whose
diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type15.C 
b/gcc/testsuite/g++.dg/cpp1z/noexcept-type15.C
new file mode 100644
index 0000000..cc5a3ed
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/noexcept-type15.C
@@ -0,0 +1,11 @@
+// PR c++/80384
+// { dg-options -std=c++17 }
+
+template<class> struct foo;
+template<bool B>
+struct foo<int() noexcept(B)> {
+    static const bool value = B; 
+};
+
+static_assert(!foo<int()>::value);
+static_assert(foo<int() noexcept>::value);

Reply via email to