aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/pointer-arith-1.c
blob: 8bf6e285d94db89c0a310c77ba569f7f3a9e5116 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* Test diagnostics for arithmetic on void and function pointers.
   Test with no special options.  */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "" } */

void *p;
void (*f)(void);

void
g (void)
{
  p + 0;
  p + 1;
  0 + p;
  1 + p;
  p - 0;
  p - 1;
  p += 0;
  p += 1;
  p -= 0;
  p -= 1;
  f + 0;
  f + 1;
  0 + f;
  1 + f;
  f - 0;
  f - 1;
  f += 0;
  f += 1;
  f -= 0;
  f -= 1;
  p[0]; /* { dg-warning "dereferencing 'void \\*' pointer" } */
  0[p]; /* { dg-warning "dereferencing 'void \\*' pointer" } */
  f[0]; /* { dg-error "subscripted value is pointer to function" } */
  0[f]; /* { dg-error "subscripted value is pointer to function" } */
  p - p;
  f - f;
}