OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [gcc.dg/] [uninit-6.c] - Diff between revs 298 and 338

Only display areas with differences | Details | Blame | View Log

Rev 298 Rev 338
/* Spurious uninitialized variable warnings.
/* Spurious uninitialized variable warnings.
   This one inspired by java/class.c:build_utf8_ref.  */
   This one inspired by java/class.c:build_utf8_ref.  */
 
 
/* { dg-do compile } */
/* { dg-do compile } */
/* { dg-options "-O -Wuninitialized" } */
/* { dg-options "-O -Wuninitialized" } */
 
 
#include <stddef.h>
#include <stddef.h>
 
 
struct tree
struct tree
{
{
    struct tree *car;
    struct tree *car;
    struct tree *cdr;
    struct tree *cdr;
    int type, data;
    int type, data;
};
};
 
 
extern void *malloc(size_t);
extern void *malloc(size_t);
 
 
#define INTEGER_T 1
#define INTEGER_T 1
#define PTR_T     2
#define PTR_T     2
 
 
#define APPEND(TREE, LAST, TYPE, VALUE)                         \
#define APPEND(TREE, LAST, TYPE, VALUE)                         \
do {                                                            \
do {                                                            \
     struct tree *tmp = malloc (sizeof (struct tree));          \
     struct tree *tmp = malloc (sizeof (struct tree));          \
     tmp->car = 0; tmp->cdr = 0; tmp->type = TYPE;                \
     tmp->car = 0; tmp->cdr = 0; tmp->type = TYPE;                \
     tmp->data = VALUE;                                         \
     tmp->data = VALUE;                                         \
     if (TREE->car)                                             \
     if (TREE->car)                                             \
         LAST->cdr = tmp;                                       \
         LAST->cdr = tmp;                                       \
     else                                                       \
     else                                                       \
         TREE->car = tmp;                                       \
         TREE->car = tmp;                                       \
     LAST = tmp;                                                \
     LAST = tmp;                                                \
} while(0)
} while(0)
 
 
struct tree *
struct tree *
make_something(int a, int b, int c)
make_something(int a, int b, int c)
{
{
    struct tree *rv;
    struct tree *rv;
    struct tree *field;
    struct tree *field;
 
 
    rv = malloc (sizeof (struct tree));
    rv = malloc (sizeof (struct tree));
    rv->car = 0;
    rv->car = 0;
 
 
    APPEND(rv, field, INTEGER_T, a);  /* { dg-bogus "field" "uninitialized variable warning" } */
    APPEND(rv, field, INTEGER_T, a);  /* { dg-bogus "field" "uninitialized variable warning" } */
    APPEND(rv, field, PTR_T, b);
    APPEND(rv, field, PTR_T, b);
    APPEND(rv, field, INTEGER_T, c);
    APPEND(rv, field, INTEGER_T, c);
 
 
    return rv;
    return rv;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.