diff mbox series

c++: ICE on invalid with NSDMI in C++98 [PR98352]

Message ID 20210326194123.134414-1-polacek@redhat.com
State New
Headers show
Series c++: ICE on invalid with NSDMI in C++98 [PR98352] | expand

Commit Message

Marek Polacek March 26, 2021, 7:41 p.m. UTC
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 (and a small tweak to the new test).

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

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                         | 2 +-
 gcc/testsuite/g++.dg/cpp0x/inh-ctor37.C | 2 +-
 gcc/testsuite/g++.dg/cpp0x/nsdmi17.C    | 8 ++++++++
 3 files changed, 10 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/nsdmi17.C


base-commit: c314741a539244a947b94ac045611746c0f072e0

Comments

Jason Merrill March 26, 2021, 7:53 p.m. UTC | #1
On 3/26/21 3:41 PM, Marek Polacek wrote:
> 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 (and a small tweak to the new test).
> 
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

OK.

> 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                         | 2 +-
>   gcc/testsuite/g++.dg/cpp0x/inh-ctor37.C | 2 +-
>   gcc/testsuite/g++.dg/cpp0x/nsdmi17.C    | 8 ++++++++
>   3 files changed, 10 insertions(+), 2 deletions(-)
>   create mode 100644 gcc/testsuite/g++.dg/cpp0x/nsdmi17.C
> 
> diff --git a/gcc/cp/method.c b/gcc/cp/method.c
> index 25c1e681b99..8ae7496f023 100644
> --- a/gcc/cp/method.c
> +++ b/gcc/cp/method.c
> @@ -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.  */
> diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor37.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor37.C
> index 7d12b534d95..a14874f4632 100644
> --- a/gcc/testsuite/g++.dg/cpp0x/inh-ctor37.C
> +++ b/gcc/testsuite/g++.dg/cpp0x/inh-ctor37.C
> @@ -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
> index 00000000000..e69d6ced49b
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi17.C
> @@ -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;
> 
> base-commit: c314741a539244a947b94ac045611746c0f072e0
>
diff mbox series

Patch

diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 25c1e681b99..8ae7496f023 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -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.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor37.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor37.C
index 7d12b534d95..a14874f4632 100644
--- a/gcc/testsuite/g++.dg/cpp0x/inh-ctor37.C
+++ b/gcc/testsuite/g++.dg/cpp0x/inh-ctor37.C
@@ -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
index 00000000000..e69d6ced49b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi17.C
@@ -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;