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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [Warray-bounds.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do compile } */
2
/* { dg-options "-O2 -Warray-bounds" } */
3
 
4
int a[10];
5
 
6
static inline int n(void) {
7
    __SIZE_TYPE__ strlen(const char *s);
8
    return strlen("12345");
9
}
10
 
11
void g(int *p);
12
void h(int p);
13
 
14
int* f(void) {
15
    int b[10];
16
    int i;
17
    struct {
18
       int c[10];
19
    } c;
20
 
21
    a[-1] = 0;             /* { dg-warning "6:array subscript" } */
22
    a[ 0] = 0;
23
    a[ 1] = 0;
24
 
25
 
26
    a[ 9] = 0;
27
    a[10] = 0;             /* { dg-warning "6:array subscript" } */
28
    a[11] = 0;             /* { dg-warning "6:array subscript" } */
29
    a[2 * n() - 11] = 1;    /* { dg-warning "6:array subscript" } */
30
    a[2 * n() - 10] = 1;
31
    a[2 * n() -  1] = 1;
32
    a[2 * n() -  0] = 1;    /* { dg-warning "6:array subscript" } */
33
 
34
    b[-1] = 0;             /* { dg-warning "6:array subscript" } */
35
    b[ 0] = 0;
36
    b[ 1] = 0;
37
    b[ 9] = 0;
38
    b[10] = 0;             /* { dg-warning "6:array subscript" } */
39
    b[11] = 0;             /* { dg-warning "6:array subscript" } */
40
    b[2 * n() - 11] = 1;    /* { dg-warning "6:array subscript" } */
41
    b[2 * n() - 10] = 1;
42
    b[2 * n() -  1] = 1;
43
    b[2 * n() -  0] = 1;    /* { dg-warning "array subscript" } */
44
 
45
    c.c[-1] = 0;           /* { dg-warning "8:array subscript" } */
46
    c.c[ 0] = 0;
47
    c.c[ 1] = 0;
48
    c.c[ 9] = 0;
49
    c.c[10] = 0;           /* { dg-warning "8:array subscript" } */
50
    c.c[11] = 0;           /* { dg-warning "8:array subscript" } */
51
    c.c[2 * n() - 11] = 1;  /* { dg-warning "8:array subscript" } */
52
    c.c[2 * n() - 10] = 1;
53
    c.c[2 * n() -  1] = 1;
54
    c.c[2 * n() -  0] = 1;  /* { dg-warning "8:array subscript" } */
55
 
56
    g(&a[8]);
57
    g(&a[9]);
58
    g(&a[10]);
59
    g(&a[11]);             /* { dg-warning "array subscript" } */
60
    g(&a[-30]+10);             /* { dg-warning "array subscript" } */
61
    g(&a[-30]+30);
62
 
63
    g(&b[10]);
64
    g(&c.c[10]);
65
    g(&b[11]);             /* { dg-warning "array subscript" } */
66
    g(&c.c[11]);           /* { dg-warning "array subscript" } */
67
 
68
    g(&a[0]);
69
    g(&b[0]);
70
    g(&c.c[0]);
71
 
72
    g(&a[-1]);             /* { dg-warning "array subscript" } */
73
    g(&b[-1]);             /* { dg-warning "array subscript" } */
74
    h(sizeof a[-1]);
75
    h(sizeof a[10]);
76
    h(sizeof b[-1]);
77
    h(sizeof b[10]);
78
    h(sizeof c.c[-1]);
79
    h(sizeof c.c[10]);
80
 
81
    if (10 < 10)
82
       a[10] = 0;
83
    if (10 < 10)
84
       b[10] = 0;
85
    if (-1 >= 0)
86
       c.c[-1] = 0;
87
 
88
    for (i = 20; i < 30; ++i)
89
             a[i] = 1;       /* { dg-warning "15:array subscript" } */
90
 
91
    return a;
92
}
93
 

powered by: WebSVN 2.1.0

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