c++: ICE on invalid with NSDMI in C++98 [PR98352]
authorMarek Polacek <polacek@redhat.com>
Fri, 26 Mar 2021 15:20:03 +0000 (11:20 -0400)
committerMarek Polacek <polacek@redhat.com>
Fri, 26 Mar 2021 20:12:08 +0000 (16:12 -0400)
NSDMIs are a C++11 thing, and here we ICE with them on the non-C++11
path.  Fortunately all we need is a small tweak to my recent r11-7835
patch.

gcc/cp/ChangeLog:

PR c++/98352
* method.c (implicitly_declare_fn): Pass &raises to
synthesized_method_walk.

gcc/testsuite/ChangeLog:

PR c++/98352
* g++.dg/cpp0x/inh-ctor37.C: Remove dg-error.
* g++.dg/cpp0x/nsdmi17.C: New test.

gcc/cp/method.c
gcc/testsuite/g++.dg/cpp0x/inh-ctor37.C
gcc/testsuite/g++.dg/cpp0x/nsdmi17.C [new file with mode: 0644]

index 25c1e68..8ae7496 100644 (file)
@@ -3002,7 +3002,7 @@ implicitly_declare_fn (special_function_kind kind, tree type,
             member initializer (c++/89914).  Also, in C++98, we might have
             failed to deduce RAISES, so try again but complain this time.  */
          if (cxx_dialect < cxx11)
-           synthesized_method_walk (type, kind, const_p, nullptr, nullptr,
+           synthesized_method_walk (type, kind, const_p, &raises, nullptr,
                                     nullptr, nullptr, /*diag=*/true,
                                     &inherited_ctor, inherited_parms);
          /* We should have seen an error at this point.  */
index 7d12b53..a14874f 100644 (file)
@@ -22,5 +22,5 @@ struct S { S(B<A> *); };
 S
 fn ()
 {
-  return S(new B<A>(10.5)); // { dg-error "no matching function" "" { target c++98_only } }
+  return S(new B<A>(10.5));
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi17.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi17.C
new file mode 100644 (file)
index 0000000..e69d6ce
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/98352
+// { dg-do compile }
+
+struct A {
+  int i = (A(), 42); // { dg-error "default member initializer" }
+// { dg-error "only available" "" { target c++98_only } .-1 }
+};
+A a;