re PR c++/89488 (ICE in merge_exception_specifiers, at cp/typeck2.c:2395)
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 27 Feb 2019 10:02:23 +0000 (10:02 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 27 Feb 2019 10:02:23 +0000 (10:02 +0000)
/cp
2019-02-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/89488
* method.c (process_subob_fn): When maybe_instantiate_noexcept
returns false don't call merge_exception_specifiers.

/testsuite
2019-02-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/89488
* g++.dg/cpp0x/nsdmi15.C: New.

/cp
2019-02-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/88987
* parser.c (cp_parser_noexcept_specification_opt): Return NULL_TREE
for a non-constant parsed expression.

/testsuite
2019-02-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/88987
* g++.dg/cpp0x/pr88987.C: New.

From-SVN: r269245

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nsdmi15.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr88987.C [new file with mode: 0644]

index 6344e4e5febcfe1edec700ac81646735c8a7f82a..1ce758b15f668605d565ed4fc4158ec3c8136a40 100644 (file)
@@ -1,3 +1,15 @@
+2019-02-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/89488
+       * method.c (process_subob_fn): When maybe_instantiate_noexcept
+       returns false don't call merge_exception_specifiers.
+
+2019-02-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/88987
+       * parser.c (cp_parser_noexcept_specification_opt): Return NULL_TREE
+       for a non-constant parsed expression.
+
 2019-02-26  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/89481
index 6e0df68273efab1f0f2cebf06fcd0fcb21074424..477d3271f59709ab01f6b643cc92bc80eee865bb 100644 (file)
@@ -1256,9 +1256,13 @@ process_subob_fn (tree fn, tree *spec_p, bool *trivial_p,
 
   if (spec_p)
     {
-      maybe_instantiate_noexcept (fn);
-      tree raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn));
-      *spec_p = merge_exception_specifiers (*spec_p, raises);
+      if (!maybe_instantiate_noexcept (fn))
+       *spec_p = error_mark_node;
+      else
+       {
+         tree raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn));
+         *spec_p = merge_exception_specifiers (*spec_p, raises);
+       }
     }
 
   if (!trivial_fn_p (fn) && !dtor_from_ctor)
index e976008e94dd4e269168636e9b446f00e5cec1d5..d9824e40803e728a20b49453121ff224eb1c4e33 100644 (file)
@@ -25143,7 +25143,17 @@ cp_parser_noexcept_specification_opt (cp_parser* parser,
              parser->type_definition_forbidden_message
              = G_("types may not be defined in an exception-specification");
 
-             expr = cp_parser_constant_expression (parser);
+             bool non_constant_p;
+             expr
+               = cp_parser_constant_expression (parser,
+                                                /*allow_non_constant=*/true,
+                                                &non_constant_p);
+             if (non_constant_p
+                 && !require_potential_rvalue_constant_expression (expr))
+               {
+                 expr = NULL_TREE;
+                 return_cond = true;
+               }
 
              /* Restore the saved message.  */
              parser->type_definition_forbidden_message = saved_message;
index 71ff3fa9aa99abe6191cf6d6d524e4289cc93e1a..2365a4f8736d2b129f7633303e46bec6a2196826 100644 (file)
@@ -1,3 +1,13 @@
+2019-02-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/89488
+       * g++.dg/cpp0x/nsdmi15.C: New.
+
+2019-02-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/88987
+       * g++.dg/cpp0x/pr88987.C: New.
+
 2019-02-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/89280
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi15.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi15.C
new file mode 100644 (file)
index 0000000..32bdad0
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/89488
+// { dg-do compile { target c++11 } }
+
+struct zl {
+  struct {
+    int x2 = zl ();  // { dg-error "default member" }
+  } fx;
+};
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr88987.C b/gcc/testsuite/g++.dg/cpp0x/pr88987.C
new file mode 100644 (file)
index 0000000..c26b571
--- /dev/null
@@ -0,0 +1,9 @@
+// { dg-do compile { target c++11 } }
+
+int sm;
+
+template <typename T> T
+pk () noexcept (sm)  // { dg-error "constant expression" }
+{
+  return 0;
+}