PR c++/80384 - ICE with dependent noexcept-specifier
authorJason Merrill <jason@redhat.com>
Fri, 9 Jun 2017 20:13:38 +0000 (16:13 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 9 Jun 2017 20:13:38 +0000 (16:13 -0400)
* pt.c (dependent_type_p_r) [FUNCTION_TYPE]: Check for dependent
noexcept-specifier.

From-SVN: r249078

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1z/noexcept-type15.C [new file with mode: 0644]

index a813de7..944b695 100644 (file)
@@ -1,5 +1,9 @@
 2017-06-09  Jason Merrill  <jason@redhat.com>
 
+       PR c++/80384 - ICE with dependent noexcept-specifier
+       * pt.c (dependent_type_p_r) [FUNCTION_TYPE]: Check for dependent
+       noexcept-specifier.
+
        * constexpr.c (potential_constant_expression_1): Allow 'this' capture.
 
 2017-06-09  Jan Hubicka  <hubicka@ucw.cz>
index ada94bd..99f5b12 100644 (file)
@@ -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 (file)
index 0000000..cc5a3ed
--- /dev/null
@@ -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);