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

Subversion Repositories openrisc

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

powered by: WebSVN 2.1.0

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