]> git.ipfire.org Git - thirdparty/gcc.git/commit
build: enable C++11 narrowing warnings
authorJason Merrill <jason@redhat.com>
Thu, 19 Sep 2024 19:50:19 +0000 (15:50 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 24 Sep 2024 12:01:10 +0000 (08:01 -0400)
commit2249c3b459510f307b4f241ea4b14f6557035152
tree3c55ee760ef2701ac5a533ccd89b8f30c063d2c9
parentf5035d7d015ebd4a7f5df5831cfc1269f9567e06
build: enable C++11 narrowing warnings

We've been using -Wno-narrowing since gcc 4.7, but at this point narrowing
diagnostics seem like a stable part of C++ and we should adjust.

This patch changes -Wno-narrowing to -Wno-error=narrowing so that narrowing
issues will still not break bootstrap, but we can see them.

The rest of the patch fixes the narrowing warnings I see in an
x86_64-pc-linux-gnu bootstrap.  In most of the cases, by adjusting the types
of various declarations so that we store the values in the same types we
compute them in, which seems worthwhile anyway.  This also allowed us to
remove a few -Wsign-compare casts.

gcc/ChangeLog:

* configure.ac (CXX_WARNING_OPTS): Change -Wno-narrowing
to -Wno-error=narrowing.
* configure: Regenerate.
* config/i386/i386.h (debugger_register_map)
(debugger64_register_map)
(svr4_debugger_register_map): Make unsigned.
* config/i386/i386.cc: Likewise.
* diagnostic-event-id.h (diagnostic_thread_id_t): Make int.
* vec.h (vec::size): Make unsigned int.
* ipa-modref.cc (escape_point::arg): Make unsigned.
(modref_lattice::add_escape_point): Use eaf_flags_t.
(update_escape_summary_1): Use eaf_flags_t, && for bool.
* pair-fusion.cc (pair_fusion_bb_info::track_access):
Make mem_size unsigned int.
* pretty-print.cc (format_phase_2): Cast va_arg to char.
* tree-ssa-loop-ch.cc (ch_base::copy_headers): Make nheaders
unsigned, remove cast.
* tree-ssa-structalias.cc (bitpos_of_field): Return unsigned.
(push_fields_onto_fieldstack):Make offset unsigned, remove cast.
* tree-vect-slp.cc (vect_prologue_cost_for_slp): Use nelt_limit.
* tree-vect-stmts.cc (vect_truncate_gather_scatter_offset):
Make scale unsigned.
(vectorizable_operation): Make ncopies unsigned.
* rtl-ssa/member-fns.inl: Make num_accesses unsigned int.
14 files changed:
gcc/config/i386/i386.cc
gcc/config/i386/i386.h
gcc/configure
gcc/configure.ac
gcc/diagnostic-event-id.h
gcc/ipa-modref.cc
gcc/pair-fusion.cc
gcc/pretty-print.cc
gcc/rtl-ssa/member-fns.inl
gcc/tree-ssa-loop-ch.cc
gcc/tree-ssa-structalias.cc
gcc/tree-vect-slp.cc
gcc/tree-vect-stmts.cc
gcc/vec.h