]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: make -fpermissive avoid -Werror=narrowing
authorJason Merrill <jason@redhat.com>
Fri, 12 May 2023 16:19:25 +0000 (12:19 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 1 Jun 2023 03:17:37 +0000 (23:17 -0400)
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

index 8724877058fbcf805810c6681954ac5f47977c3d..1c204c8612b185652cad06676d81bcac14181a28 100644 (file)
@@ -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",