File: uninit-6-O0.c

package info (click to toggle)
gcc-riscv64-unknown-elf 8.3.0.2019.08%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 680,956 kB
  • sloc: ansic: 3,237,715; cpp: 896,882; ada: 772,854; f90: 144,254; asm: 68,788; makefile: 67,456; sh: 29,743; exp: 28,045; objc: 15,273; fortran: 11,885; python: 7,369; pascal: 5,375; awk: 3,725; perl: 2,872; yacc: 316; xml: 311; ml: 285; lex: 198; haskell: 122
file content (47 lines) | stat: -rw-r--r-- 1,057 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* Spurious uninitialized variable warnings.
   This one inspired by java/class.c:build_utf8_ref.  */

/* { dg-do compile } */
/* { dg-options "-Wuninitialized -ftrack-macro-expansion=2" } */

#include <stddef.h>

struct tree
{
    struct tree *car;
    struct tree *cdr;
    int type, data;
};

extern void *malloc(size_t);

#define INTEGER_T 1
#define PTR_T	  2

#define APPEND(TREE, LAST, TYPE, VALUE)				\
do {								\
     struct tree *tmp = malloc (sizeof (struct tree));		\
     tmp->car = 0; tmp->cdr = 0; tmp->type = TYPE;		\
     tmp->data = VALUE;						\
     if (TREE->car)						\
	 LAST->cdr = tmp;	  /* { dg-bogus "field" "uninitialized variable warning" { xfail *-*-* } } */				\
     else							\
	 TREE->car = tmp;					\
     LAST = tmp;						\
} while(0)
 
struct tree *
make_something(int a, int b, int c)
{
    struct tree *rv;
    struct tree *field;

    rv = malloc (sizeof (struct tree));
    rv->car = 0;

    APPEND(rv, field, INTEGER_T, a);
    APPEND(rv, field, PTR_T, b);
    APPEND(rv, field, INTEGER_T, c);

    return rv;
}