summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wstringop-overflow-67.c
blob: 7b8f3f014c63b359ebf6ebbfca6735b41dd3bb14 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* PR middle-end/100571 - bogus -Wstringop-overflow with VLA of elements
   larger than byte
   { dg-do compile }
   { dg-options "-O2 -Wall" } */

__attribute__ ((access (read_only, 1, 2))) void fro (int *, int);
__attribute__ ((access (write_only, 1, 2))) void fwo (int *, int);
__attribute__ ((access (read_write, 1, 2))) void frw (int *, int);

extern __SIZE_TYPE__ n;

void alloca_ro (void)
{
  int *a = __builtin_alloca (n * sizeof *a);
  a[0] = 0;
  fro (a, n);
}

void alloca_wo (void)
{
  int *a = __builtin_alloca (n * sizeof *a);
  fwo (a, n);
}

void alloca_rw (void)
{
  int *a = __builtin_alloca (n * sizeof *a);
  a[0] = 0;
  frw (a, n);
}


void calloc_ro (void)
{
  int *a = __builtin_calloc (n, sizeof *a);
  fro (a, n);
}

void calloc_wo (void)
{
  int *a = __builtin_calloc (n, sizeof *a);
  fwo (a, n);
}

void calloc_rw (void)
{
  int *a = __builtin_calloc (n, sizeof *a);
  a[0] = 0;
  frw (a, n);
}


void malloc_ro (void)
{
  int *a = __builtin_malloc (n * sizeof *a);
  a[0] = 0;
  fro (a, n);
}

void malloc_wo (void)
{
  int *a = __builtin_malloc (n * sizeof *a);
  fwo (a, n);
}

void malloc_rw (void)
{
  int *a = __builtin_malloc (n * sizeof *a);
  a[0] = 0;
  frw (a, n);
}


void vla_ro (void)
{
  int a[n];
  a[0] = 0;
  fro (a, n);
}

void vla_wo (void)
{
  int a[n];
  fwo (a, n);
}

void vla_rw (void)
{
  int a[n];
  a[0] = 0;
  frw (a, n);
}