GCC modified for the FreeChainXenon project
Find a file
Jakub Jelinek e7dd72aefe c: Split -Wcalloc-transposed-args warning from -Walloc-size, -Walloc-size fixes
The following patch changes -Walloc-size warning to no longer warn
about int *p = calloc (1, sizeof (int));, because as discussed earlier,
the size is IMNSHO sufficient in that case, for alloc_size with 2
arguments warns if the product of the 2 arguments is insufficiently small.

Also, it warns also for explicit casts of malloc/calloc etc. calls
rather than just implicit, so not just
  int *p = malloc (1);
but also
  int *p = (int *) malloc (1);

It also fixes some ICEs where the code didn't verify the alloc_size
arguments properly (Walloc-size-5.c testcase ICEs with vanilla trunk).

And lastly, it introduces a coding style warning, -Wcalloc-transposed-args
to warn for calloc (sizeof (struct S), 1) and similar calls (regardless
of what they are cast to, warning whenever first argument is sizeof and
the second is not).

2023-12-20  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* doc/invoke.texi (-Walloc-size): Add to the list of
	warning options, remove unnecessary line-break.
	(-Wcalloc-transposed-args): Document new warning.
gcc/c-family/
	* c.opt (Wcalloc-transposed-args): New warning.
	* c-common.h (warn_for_calloc, warn_for_alloc_size): Declare.
	* c-warn.cc (warn_for_calloc, warn_for_alloc_size): New functions.
gcc/c/
	* c-parser.cc (c_parser_postfix_expression_after_primary): Grow
	sizeof_arg and sizeof_arg_loc arrays to 6 elements.  Call
	warn_for_calloc if warn_calloc_transposed_args for functions with
	alloc_size type attribute with 2 arguments.
	(c_parser_expr_list): Use 6 instead of 3.
	* c-typeck.cc (build_c_cast): Call warn_for_alloc_size for casts
	of calls to functions with alloc_size type attribute.
	(convert_for_assignment): Likewise.
gcc/testsuite/
	* gcc.dg/Walloc-size-4.c: New test.
	* gcc.dg/Walloc-size-5.c: New test.
	* gcc.dg/Wcalloc-transposed-args-1.c: New test.
2023-12-20 11:31:18 +01:00
.github Minor formatting fix for newly-added file from previous commit 2023-11-01 19:28:56 -04:00
c++tools
config Daily bump. 2023-12-01 00:17:36 +00:00
contrib Daily bump. 2023-12-15 00:17:17 +00:00
fixincludes Daily bump. 2023-11-23 00:18:14 +00:00
gcc c: Split -Wcalloc-transposed-args warning from -Walloc-size, -Walloc-size fixes 2023-12-20 11:31:18 +01:00
gnattools
gotools Daily bump. 2023-11-04 00:16:45 +00:00
include Daily bump. 2023-12-16 00:17:35 +00:00
INSTALL
libada
libatomic Daily bump. 2023-12-16 00:17:35 +00:00
libbacktrace Daily bump. 2023-12-01 00:17:36 +00:00
libcc1 Daily bump. 2023-12-07 00:17:06 +00:00
libcody
libcpp Daily bump. 2023-12-14 00:18:00 +00:00
libdecnumber
libffi Daily bump. 2023-10-27 00:17:12 +00:00
libgcc strub: sparc: omit frame in strub_leave [PR112917] 2023-12-20 05:18:17 -03:00
libgfortran Daily bump. 2023-12-20 00:17:48 +00:00
libgm2 Daily bump. 2023-12-14 00:18:00 +00:00
libgo libgo: update configure.ac to upstream GCC 2023-11-30 13:23:53 -08:00
libgomp Daily bump. 2023-12-19 00:17:36 +00:00
libgrust Daily bump. 2023-12-15 00:17:17 +00:00
libiberty Daily bump. 2023-12-06 00:17:50 +00:00
libitm Daily bump. 2023-10-23 00:16:43 +00:00
libobjc Daily bump. 2023-10-23 00:16:43 +00:00
libphobos Daily bump. 2023-12-19 00:17:36 +00:00
libquadmath Daily bump. 2023-12-13 00:17:49 +00:00
libsanitizer Daily bump. 2023-11-29 00:17:27 +00:00
libssp Daily bump. 2023-10-23 00:16:43 +00:00
libstdc++-v3 Daily bump. 2023-12-19 00:17:36 +00:00
libvtv Daily bump. 2023-10-23 00:16:43 +00:00
lto-plugin Daily bump. 2023-10-23 00:16:43 +00:00
maintainer-scripts Daily bump. 2023-11-14 12:23:39 +00:00
zlib Daily bump. 2023-10-23 00:16:43 +00:00
.dir-locals.el
.gitattributes
.gitignore *: add modern gettext 2023-11-14 00:47:11 +01:00
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2023-12-15 00:17:17 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure build: Add libgrust as compilation modules 2023-12-14 13:58:57 +01:00
configure.ac build: Add libgrust as compilation modules 2023-12-14 13:58:57 +01:00
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
depcomp
install-sh
libtool-ldflags
libtool.m4 Build: fix error in fixinclude configure 2023-11-22 11:54:33 +01:00
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS libgrust: Add entry for maintainers 2023-12-14 13:34:20 +01:00
Makefile.def build: Add libgrust as compilation modules 2023-12-14 13:58:57 +01:00
Makefile.in build: Add libgrust as compilation modules 2023-12-14 13:58:57 +01:00
Makefile.tpl Makefile.tpl: Avoid race condition in generating site.exp from the top level 2023-11-19 11:07:09 -05:00
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
SECURITY.txt secpol: consistent indentation 2023-10-05 12:00:39 -04:00
symlink-tree
test-driver
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.