testsuite: Add -fno-tree-loop-distribute-patterns.

In gcc.dg/Wuse-after-free-2.c we try to detect a use-after-free.  The
test's while loop is converted into a rawmemchr builtin making
it impossible to determine that the pointers *p and *q are related.

Therefore, disable the tree loop distribute patterns pass for this test.

gcc/testsuite/ChangeLog:

	* gcc.dg/Wuse-after-free-2.c:
	Add -fno-tree-loop-distribute-patterns in order to avoid
	rawmemchr.
This commit is contained in:
Robin Dapp 2022-04-01 09:52:56 +02:00
parent e3174d6183
commit 321d1dcf61
1 changed files with 3 additions and 1 deletions

View File

@ -1,6 +1,6 @@
/* PR middle-end/104232 - spurious -Wuse-after-free after conditional free
{ dg-do compile }
{ dg-options "-O2 -Wall" } */
{ dg-options "-O2 -Wall -fno-tree-loop-distribute-patterns" } */
void free (void*);
@ -107,6 +107,8 @@ int warn_cond_loop (char *p)
{
char *q = p;
/* -fno-tree-loop-distribute-patterns ensures this does not get converted
into rawmemchr (making q and p unrelated). */
while (*q)
++q;