PR middle-end/65182 - -Wuninitialized fails when pointer to variable later passed to function
gcc/testsuite: PR middle-end/65182 * gcc.dg/uninit-pr65182.c: New test.
This commit is contained in:
parent
a2531859bf
commit
31199d95de
44
gcc/testsuite/gcc.dg/uninit-pr65182.c
Normal file
44
gcc/testsuite/gcc.dg/uninit-pr65182.c
Normal file
@ -0,0 +1,44 @@
|
||||
/* PR middle-end/65182 - -Wuninitialized fails when pointer to variable
|
||||
later passed to function
|
||||
{ dg-do compile }
|
||||
{ dg-options "-O0 -Wall" } */
|
||||
|
||||
void bar (int *a);
|
||||
|
||||
int baz (void);
|
||||
|
||||
__attribute__ ((noipa)) void foo_O0 (int *b)
|
||||
{
|
||||
int a;
|
||||
|
||||
if (a) // { dg-warning "\\\[-Wuninitialized" }
|
||||
{
|
||||
*b = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
bar (&a);
|
||||
|
||||
a = baz ();
|
||||
|
||||
*b = a + 2;
|
||||
}
|
||||
|
||||
#pragma GCC optimize ("2")
|
||||
|
||||
__attribute__ ((noipa)) void foo_O2 (int *b)
|
||||
{
|
||||
int a;
|
||||
|
||||
if (a) // { dg-warning "\\\[-Wuninitialized" }
|
||||
{
|
||||
*b = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
bar (&a);
|
||||
|
||||
a = baz ();
|
||||
|
||||
*b = a + 3;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user