public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: fix error reporting routines re-entered ICE [PR110175]
@ 2023-06-23 22:25 Marek Polacek
  2023-06-28 15:50 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2023-06-23 22:25 UTC (permalink / raw)
  To: GCC Patches, Jason Merrill

Here we get the "error reporting routines re-entered" ICE because
of an unguarded use of warning_at.  While at it, I added a check
for a warning_at just above it.

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

	PR c++/110175

gcc/cp/ChangeLog:

	* typeck.cc (cp_build_unary_op): Check tf_warning before warning.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/decltype-110175.C: New test.
---
 gcc/cp/typeck.cc                             | 5 +++--
 gcc/testsuite/g++.dg/cpp0x/decltype-110175.C | 6 ++++++
 2 files changed, 9 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype-110175.C

diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index da591dafc8f..859b133a18d 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -7561,7 +7561,8 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
 	/* [depr.volatile.type] "Postfix ++ and -- expressions and
 	   prefix ++ and -- expressions of volatile-qualified arithmetic
 	   and pointer types are deprecated."  */
-	if (TREE_THIS_VOLATILE (arg) || CP_TYPE_VOLATILE_P (TREE_TYPE (arg)))
+	if ((TREE_THIS_VOLATILE (arg) || CP_TYPE_VOLATILE_P (TREE_TYPE (arg)))
+	    && (complain & tf_warning))
 	  warning_at (location, OPT_Wvolatile,
 		      "%qs expression of %<volatile%>-qualified type is "
 		      "deprecated",
@@ -7592,7 +7593,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
 		    return error_mark_node;
 		  }
 		/* Otherwise, [depr.incr.bool] says this is deprecated.  */
-		else
+		else if (complain & tf_warning)
 		  warning_at (location, OPT_Wdeprecated,
 			      "use of an operand of type %qT "
 			      "in %<operator++%> is deprecated",
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-110175.C b/gcc/testsuite/g++.dg/cpp0x/decltype-110175.C
new file mode 100644
index 00000000000..39643cafcf8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype-110175.C
@@ -0,0 +1,6 @@
+// PR c++/110175
+// { dg-do compile { target c++11 } }
+
+template<class T> auto f(T t) -> decltype(++t) { return t; } // { dg-warning "reference" "" { target c++14_down } }
+void f(...) {}
+void g() { f(true); }

base-commit: 5388a43f6a3f348929292998bd6d0c1da6f006de
-- 
2.41.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] c++: fix error reporting routines re-entered ICE [PR110175]
  2023-06-23 22:25 [PATCH] c++: fix error reporting routines re-entered ICE [PR110175] Marek Polacek
@ 2023-06-28 15:50 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2023-06-28 15:50 UTC (permalink / raw)
  To: Marek Polacek, GCC Patches

On 6/23/23 18:25, Marek Polacek wrote:
> Here we get the "error reporting routines re-entered" ICE because
> of an unguarded use of warning_at.  While at it, I added a check
> for a warning_at just above it.
> 
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

OK.

> 	PR c++/110175
> 
> gcc/cp/ChangeLog:
> 
> 	* typeck.cc (cp_build_unary_op): Check tf_warning before warning.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/cpp0x/decltype-110175.C: New test.
> ---
>   gcc/cp/typeck.cc                             | 5 +++--
>   gcc/testsuite/g++.dg/cpp0x/decltype-110175.C | 6 ++++++
>   2 files changed, 9 insertions(+), 2 deletions(-)
>   create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype-110175.C
> 
> diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
> index da591dafc8f..859b133a18d 100644
> --- a/gcc/cp/typeck.cc
> +++ b/gcc/cp/typeck.cc
> @@ -7561,7 +7561,8 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
>   	/* [depr.volatile.type] "Postfix ++ and -- expressions and
>   	   prefix ++ and -- expressions of volatile-qualified arithmetic
>   	   and pointer types are deprecated."  */
> -	if (TREE_THIS_VOLATILE (arg) || CP_TYPE_VOLATILE_P (TREE_TYPE (arg)))
> +	if ((TREE_THIS_VOLATILE (arg) || CP_TYPE_VOLATILE_P (TREE_TYPE (arg)))
> +	    && (complain & tf_warning))
>   	  warning_at (location, OPT_Wvolatile,
>   		      "%qs expression of %<volatile%>-qualified type is "
>   		      "deprecated",
> @@ -7592,7 +7593,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
>   		    return error_mark_node;
>   		  }
>   		/* Otherwise, [depr.incr.bool] says this is deprecated.  */
> -		else
> +		else if (complain & tf_warning)
>   		  warning_at (location, OPT_Wdeprecated,
>   			      "use of an operand of type %qT "
>   			      "in %<operator++%> is deprecated",
> diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-110175.C b/gcc/testsuite/g++.dg/cpp0x/decltype-110175.C
> new file mode 100644
> index 00000000000..39643cafcf8
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/decltype-110175.C
> @@ -0,0 +1,6 @@
> +// PR c++/110175
> +// { dg-do compile { target c++11 } }
> +
> +template<class T> auto f(T t) -> decltype(++t) { return t; } // { dg-warning "reference" "" { target c++14_down } }
> +void f(...) {}
> +void g() { f(true); }
> 
> base-commit: 5388a43f6a3f348929292998bd6d0c1da6f006de


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-28 15:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-23 22:25 [PATCH] c++: fix error reporting routines re-entered ICE [PR110175] Marek Polacek
2023-06-28 15:50 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).