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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [pr36902.c] - Blame information for rev 754

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

Line No. Rev Author Line
1 689 jeremybenn
/* PR middle-end/36902 Array bound warning with dead code after optimization */
2
/* { dg-do compile } */
3
/* { dg-options "-O2 -Warray-bounds -Wall -Wextra" } */
4
typedef unsigned char __u8;
5
typedef unsigned short __u16;
6
 
7
static inline unsigned char *
8
foo(unsigned char * to, const unsigned char * from, int n)
9
{
10
  switch ( n )
11
    {
12
    case 3:
13
      *to = *from;
14
      break;
15
    case 5:
16
      to[4] = from [4];
17
      break;
18
    }
19
  return to;
20
}
21
 
22
struct {
23
  int    size_of_select;
24
  unsigned char pcr_select[4];
25
} sel;
26
 
27
int bar(void)
28
{
29
  static unsigned char buf[64];
30
 
31
  sel.size_of_select = 3;
32
  foo(buf, sel.pcr_select, sel.size_of_select);
33
 
34
  return 1;
35
}
36
 
37
 
38
static inline unsigned char *
39
foo2(unsigned char * to, const unsigned char * from, int n)
40
{
41
  switch ( n )
42
    {
43
    case 3:
44
      *to = *from;
45
      break;
46
    case 5:
47
      to[4] = from [4]; /* { dg-warning "array subscript is above array bounds" "" { xfail *-*-* } } */
48
      break;
49
    }
50
  return to;
51
}
52
 
53
int baz(void)
54
{
55
  static unsigned char buf[64];
56
 
57
  sel.size_of_select = 5;
58
  foo2(buf, sel.pcr_select, sel.size_of_select);
59
 
60
  return 1;
61
}

powered by: WebSVN 2.1.0

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