[PATCH 3/3] gimple-fold: Use ranges to simplify strncat and snprintf

Siddhesh Poyarekar siddhesh@gotplt.org
Mon Nov 15 10:41:39 GMT 2021


On 11/12/21 01:11, Siddhesh Poyarekar wrote:
> Remove the warnings for strncat since it is already handled (and even
> the error messages look identical) in gimple-ssa-warn-access.  Instead,
> use len range to determine if it is within bounds of source and
> destination and simplify it to strcat if it's safe.
> 
> Likewise for snprintf, use ranges to determine if it can be transformed
> to strcpy.
> 
> gcc/ChangeLog:
> 
> 	* gimple-fold.c (gimple_fold_builtin_strncat): Remove warnings
> 	and use ranges to determine if it is safe to transform to
> 	strcat.
> 	(gimple_fold_builtin_snprintf): Likewise.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* gcc.dg/fold-stringops-2.c: Define size_t.
> 	(safe1): Adjust.
> 	(safe4): New test.
> 	* gcc.dg/fold-stringops-3.c: New test.
> 

Sorry, it looks like my last test run was stale and didn't catch the 
regressions dropping warnings caused.  I'll bring back the warnings in 
v2 with ranges.

Siddhesh


More information about the Gcc-patches mailing list