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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [array-8.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Test diagnostics for array references.  */
2
/* Origin: Joseph Myers <joseph@codesourcery.com> */
3
/* { dg-do compile } */
4
/* { dg-options "-std=gnu89" } */
5
 
6
struct s { char c[1]; };
7
struct s f (void);
8
_Bool b;
9
char c;
10
enum e { E } e;
11
extern int a[];
12
int *p;
13
void *pv;
14
void (*fp)(void);
15
struct si *sip;
16
 
17
void
18
g (void)
19
{
20
  a[b];
21
  a[c];
22
  a[e];
23
  p[b];
24
  p[c];
25
  p[e];
26
  b[a];
27
  c[a];
28
  e[a];
29
  b[p];
30
  c[p];
31
  e[p];
32
  /* These two should be treated the same.  In particular, a "neither
33
     array nor pointer" bogus warning used to be given for the
34
     second.  */
35
  f().c[0];
36
  0[f().c];
37
  /* Various invalid cases.  */
38
  c[c]; /* { dg-error "error: subscripted value is neither array nor pointer" } */
39
  p[1.0]; /* { dg-error "error: array subscript is not an integer" } */
40
  1.0[a]; /* { dg-error "error: array subscript is not an integer" } */
41
  fp[0]; /* { dg-error "error: subscripted value is pointer to function" } */
42
  0[fp]; /* { dg-error "error: subscripted value is pointer to function" } */
43
  pv[0]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
44
  0[pv]; /* { dg-warning "warning: dereferencing 'void \\*' pointer" } */
45
  sip[0]; /* { dg-error "error: invalid use of undefined type 'struct si'" } */
46
  /* { dg-error "error: dereferencing pointer to incomplete type" "incomplete" { target *-*-* } 45 } */
47
  0[sip]; /* { dg-error "error: invalid use of undefined type 'struct si'" } */
48
  /* { dg-error "error: dereferencing pointer to incomplete type" "incomplete" { target *-*-* } 47 } */
49
}

powered by: WebSVN 2.1.0

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