PR c++/90490 - fix decltype issues in noexcept-specifier.
authorMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 21 Jun 2019 20:19:24 +0000 (20:19 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 21 Jun 2019 20:19:24 +0000 (20:19 +0000)
* except.c (build_noexcept_spec): Call
instantiate_non_dependent_expr_sfinae before
build_converted_constant_expr instead of calling
instantiate_non_dependent_expr after it.  Add
processing_template_decl_sentinel.

* g++.dg/cpp0x/noexcept43.C: New test.
* g++.dg/cpp0x/noexcept44.C: New test.

From-SVN: r272568

gcc/cp/ChangeLog
gcc/cp/except.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/noexcept43.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/noexcept44.C [new file with mode: 0644]

index c958318abe7209b15a8015c51e7c13ba80293755..0afd0e6debf03c172ffdbe32643073224a98f798 100644 (file)
@@ -1,3 +1,12 @@
+2019-06-21  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/90490 - fix decltype issues in noexcept-specifier.
+       * except.c (build_noexcept_spec): Call
+       instantiate_non_dependent_expr_sfinae before
+       build_converted_constant_expr instead of calling
+       instantiate_non_dependent_expr after it.  Add
+       processing_template_decl_sentinel.
+
 2019-06-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/90950
index 892d5201da983901d8faa138cfad257107962ef7..71f5d609f1006890832e8d22a82489725225c449 100644 (file)
@@ -1285,8 +1285,10 @@ build_noexcept_spec (tree expr, tsubst_flags_t complain)
   if (TREE_CODE (expr) != DEFERRED_NOEXCEPT
       && !value_dependent_expression_p (expr))
     {
+      expr = instantiate_non_dependent_expr_sfinae (expr, complain);
+      /* Don't let convert_like_real create more template codes.  */
+      processing_template_decl_sentinel s;
       expr = build_converted_constant_bool_expr (expr, complain);
-      expr = instantiate_non_dependent_expr (expr);
       expr = cxx_constant_value (expr);
     }
   if (TREE_CODE (expr) == INTEGER_CST)
index 2c80ac4bdd6b8d9855dc6adb018a125cc9f00fc8..b56645fc0cf6c177ea832916a9e022bfd1d4c701 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-21  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/90490 - fix decltype issues in noexcept-specifier.
+       * g++.dg/cpp0x/noexcept43.C: New test.
+       * g++.dg/cpp0x/noexcept44.C: New test.
+
 2019-06-21  Matthew Beliveau  <mbelivea@redhat.com>
 
        PR c++/90875 - added -Wswitch-outside-range option
@@ -13,7 +19,7 @@
 
 2019-06-21  Jeff Law  <law@redhat.com>
 
-        PR tree-optimization/90949
+       PR tree-optimization/90949
        * gcc.c-torture/execute/pr90949.c: New test.
 
 2019-06-21  Marek Polacek  <polacek@redhat.com>
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept43.C b/gcc/testsuite/g++.dg/cpp0x/noexcept43.C
new file mode 100644 (file)
index 0000000..faa7d14
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/90490
+// { dg-do compile { target c++11 } }
+
+struct R { constexpr operator bool() { return false;} };
+
+template <typename>
+struct S {
+  void g() noexcept(decltype(R{ }) { }) {
+  }
+};
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept44.C b/gcc/testsuite/g++.dg/cpp0x/noexcept44.C
new file mode 100644 (file)
index 0000000..78c9d12
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/90490
+// { dg-do compile { target c++11 } }
+
+template <typename>
+struct S {
+  void g() noexcept(decltype(int{ }) { }) {
+  }
+};