PR middle-end/89230 - Bogus uninited usage warning with printf
gcc/testsuite/ChangeLog: * gcc.dg/uninit-pr89230-1.c: New test. * gcc.dg/uninit-pr89230-2.c: Same.
This commit is contained in:
parent
2efbbba16a
commit
2dbbbe893f
25
gcc/testsuite/gcc.dg/uninit-pr89230-1.c
Normal file
25
gcc/testsuite/gcc.dg/uninit-pr89230-1.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* PR middle-end/89230 - Bogus uninited usage warning with printf
|
||||
{ dg-do compile }
|
||||
{ dg-options "-O2 -Wall" } */
|
||||
|
||||
struct S { int i, j; };
|
||||
|
||||
/* attribute__ ((malloc)) */ struct S* f (void);
|
||||
|
||||
int g (void)
|
||||
{
|
||||
struct S *p = f (), *q;
|
||||
|
||||
if (p->i || !(q = f ()) || p->j != q->i)
|
||||
{
|
||||
__builtin_printf ("%i", p->i);
|
||||
|
||||
if (p->i)
|
||||
return 1;
|
||||
|
||||
if (!q) // { dg-bogus "\\\[-Wmaybe-uninitialized" }
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
54
gcc/testsuite/gcc.dg/uninit-pr89230-2.c
Normal file
54
gcc/testsuite/gcc.dg/uninit-pr89230-2.c
Normal file
@ -0,0 +1,54 @@
|
||||
/* PR middle-end/89230 - Bogus uninited usage warning with printf
|
||||
{ dg-do compile }
|
||||
{ dg-options "-O2 -Wall" } */
|
||||
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
|
||||
extern void* memset (void*, int, size_t);
|
||||
extern int printf (const char*, ...);
|
||||
extern int rand (void);
|
||||
|
||||
struct S
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
};
|
||||
|
||||
struct H
|
||||
{
|
||||
int c;
|
||||
int d;
|
||||
};
|
||||
|
||||
void getblk (void* blk)
|
||||
{
|
||||
struct S* s = (struct S*) blk;
|
||||
memset (blk, 0, 512);
|
||||
s->a = rand () & 1;
|
||||
}
|
||||
|
||||
struct H* gethdr (void* blk)
|
||||
{
|
||||
memset (blk, 0, 512);
|
||||
return rand () & 1 ? (struct H*) blk : 0;
|
||||
}
|
||||
|
||||
int main (void)
|
||||
{
|
||||
char blk[512], tmp[512];
|
||||
struct S *s = (struct S*) blk;
|
||||
struct H *h;
|
||||
|
||||
getblk (blk);
|
||||
|
||||
if (s->a || !(h = gethdr (tmp)) || s->a != h->d) {
|
||||
|
||||
printf ("%d\n", s->b);
|
||||
if (s->a)
|
||||
printf ("s->a = %d\n", s->a);
|
||||
else if (!h)
|
||||
printf ("!h\n");
|
||||
else
|
||||
printf ("h->d = %d\n", h->d);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user