Commit 79fbdeb8 by Jakub Jelinek Committed by Jakub Jelinek

re PR c/83989 (-Wrestrict false positive with malloc-style functions)

	PR c/83989
	* gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Don't
	use SSA_NAME_VAR as base for SSA_NAMEs with non-NULL SSA_NAME_VAR.

	* c-c++-common/Wrestrict-3.c: New test.

From-SVN: r257086
parent 62f26645
2018-01-26 Jakub Jelinek <jakub@redhat.com>
PR c/83989
* gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Don't
use SSA_NAME_VAR as base for SSA_NAMEs with non-NULL SSA_NAME_VAR.
2018-01-26 Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/arc-arch.h (arc_tune_attr): Add ARC_TUNE_CORE_3.
......
......@@ -373,9 +373,6 @@ builtin_memref::builtin_memref (tree expr, tree size)
offrange[1] += off;
}
}
if (TREE_CODE (base) == SSA_NAME && SSA_NAME_VAR (base))
base = SSA_NAME_VAR (base);
}
if (size)
......
2018-01-26 Jakub Jelinek <jakub@redhat.com>
PR c/83989
* c-c++-common/Wrestrict-3.c: New test.
2018-01-26 Claudiu Zissulescu <claziss@synopsys.com>
* testsuite/gcc.target/arc/tdelegitimize_addr.c: New test.
......
/* PR c/83989 */
/* { dg-do compile } */
/* { dg-options "-O2 -Wrestrict" } */
__attribute__((__malloc__)) extern void *my_malloc (__SIZE_TYPE__);
void baz (void *);
#define SIZE 32
void
foo (void)
{
void *recmem = __builtin_malloc (SIZE);
baz (recmem);
while (1)
{
void *oldrecmem = recmem;
recmem = __builtin_malloc (SIZE);
if (!recmem)
{
__builtin_free (oldrecmem);
return;
}
__builtin_memcpy (recmem, oldrecmem, SIZE); /* { dg-bogus "accessing" } */
baz (recmem);
__builtin_free (oldrecmem);
}
}
void
bar (void)
{
void *recmem = my_malloc (SIZE);
baz (recmem);
while (1)
{
void *oldrecmem = recmem;
recmem = my_malloc (SIZE);
if (!recmem)
{
__builtin_free (oldrecmem);
return;
}
__builtin_memcpy (recmem, oldrecmem, SIZE); /* { dg-bogus "accessing" } */
baz (recmem);
__builtin_free (oldrecmem);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment