aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorQing Zhao <qing.zhao@oracle.com>2022-12-16 17:25:42 +0000
committerQing Zhao <qing.zhao@oracle.com>2022-12-16 17:25:42 +0000
commit2a27ae32fabf85685ffff758459d7ec284ccb95a (patch)
treef454c76a179f030d6b89947de1c233d6934dc7d3 /gcc/rust
parent9bb7864877ab05bf951fad66c934845351b271ce (diff)
downloadgcc-2a27ae32fabf85685ffff758459d7ec284ccb95a.zip
gcc-2a27ae32fabf85685ffff758459d7ec284ccb95a.tar.gz
gcc-2a27ae32fabf85685ffff758459d7ec284ccb95a.tar.bz2
Add a new warning option -Wstrict-flex-arrays.
'-Wstrict-flex-arrays' Warn about inproper usages of flexible array members according to the LEVEL of the 'strict_flex_array (LEVEL)' attribute attached to the trailing array field of a structure if it's available, otherwise according to the LEVEL of the option '-fstrict-flex-arrays=LEVEL'. This option is effective only when LEVEL is bigger than 0. Otherwise, it will be ignored with a warning. when LEVEL=1, warnings will be issued for a trailing array reference of a structure that have 2 or more elements if the trailing array is referenced as a flexible array member. when LEVEL=2, in addition to LEVEL=1, additional warnings will be issued for a trailing one-element array reference of a structure if the array is referenced as a flexible array member. when LEVEL=3, in addition to LEVEL=2, additional warnings will be issued for a trailing zero-length array reference of a structure if the array is referenced as a flexible array member. gcc/ChangeLog: * doc/invoke.texi: Document -Wstrict-flex-arrays option. * gimple-array-bounds.cc (check_out_of_bounds_and_warn): Add two more arguments. (array_bounds_checker::check_array_ref): Issue warnings for -Wstrict-flex-arrays. * opts.cc (finish_options): Issue warning for unsupported combination of -Wstrict_flex_arrays and -fstrict-flex-array. * tree-vrp.cc (execute_ranger_vrp): Enable the pass when warn_strict_flex_array is true. gcc/c-family/ChangeLog: * c.opt (Wstrict-flex-arrays): New option. gcc/testsuite/ChangeLog: * gcc.dg/Warray-bounds-flex-arrays-1.c: Update testing case with -Wstrict-flex-arrays. * gcc.dg/Warray-bounds-flex-arrays-2.c: Likewise. * gcc.dg/Warray-bounds-flex-arrays-3.c: Likewise. * gcc.dg/Warray-bounds-flex-arrays-4.c: Likewise. * gcc.dg/Warray-bounds-flex-arrays-5.c: Likewise. * gcc.dg/Warray-bounds-flex-arrays-6.c: Likewise. * c-c++-common/Wstrict-flex-arrays.c: New test. * gcc.dg/Wstrict-flex-arrays-2.c: New test. * gcc.dg/Wstrict-flex-arrays-3.c: New test. * gcc.dg/Wstrict-flex-arrays.c: New test.
Diffstat (limited to 'gcc/rust')
0 files changed, 0 insertions, 0 deletions