[pushed] c++: make -fpermissive avoid -Werror=narrowing

Message ID 20230601031819.1271768-1-jason@redhat.com
State Accepted
Headers
Series [pushed] c++: make -fpermissive avoid -Werror=narrowing |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Jason Merrill June 1, 2023, 3:18 a.m. UTC
  Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

Currently we make -Wnarrowing an error by default by forcing pedantic_errors
on, but for consistency -fpermissive should prevent that.

In general I'm inclined to move away from using permerror in favor of this
kind of model, with specific flags for each diagnostic.

gcc/cp/ChangeLog:

	* typeck2.cc (check_narrowing): Check flag_permissive.
---
 gcc/cp/typeck2.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


base-commit: 09ff83d4bc1405c9af803fb84bfc49d6001da47b
  

Patch

diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index 8724877058f..1c204c8612b 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -1109,7 +1109,8 @@  check_narrowing (tree type, tree init, tsubst_flags_t complain,
       else if (complain & tf_error)
 	{
 	  int savederrorcount = errorcount;
-	  global_dc->pedantic_errors = 1;
+	  if (!flag_permissive)
+	    global_dc->pedantic_errors = 1;
 	  auto s = make_temp_override (global_dc->dc_warn_system_headers, true);
 	  pedwarn (loc, OPT_Wnarrowing,
 		   "narrowing conversion of %qE from %qH to %qI",