summaryrefslogtreecommitdiff
path: root/support/regression/tests/gcc-torture-execute-pr88693.c
blob: c32db9c6102cc4cfdd7d5eb48386444ad293ca69 (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
/*
   pr88693.c from the execute part of the gcc torture tests.
 */

#include <testfwk.h>

#include <string.h>

/* PR tree-optimization/88693 */

void
foo (char *p)
{
  if (strlen (p) != 9)
    ASSERT (0);
}

void
quux (char *p)
{
  int i;
  for (i = 0; i < 100; i++)
    if (p[i] != 'x')
      ASSERT (0);
}

void
qux (void)
{
#if !(defined(__SDCC_pdk14) || defined(__SDCC_pdk15) && !defined(__SDCC_STACK_AUTO) || defined(__SDCC_mcs51)) // Lack of memory
  char b[100];
  memset (b, 'x', sizeof (b));
  quux (b);
#endif
}

void
bar (void)
{
#if !(defined(__SDCC_pdk14) || defined(__SDCC_pdk15) && !defined(__SDCC_STACK_AUTO) || defined(__SDCC_mcs51)) // Lack of memory
  static unsigned char u[9] = "abcdefghi";
  char b[100];
  memcpy (b, u, sizeof (u));
  b[sizeof (u)] = 0;
  foo (b);
#endif
}

void
baz (void)
{
#if !(defined(__SDCC_pdk14) || defined(__SDCC_pdk15) && !defined(__SDCC_STACK_AUTO) || defined(__SDCC_mcs51)) // Lack of memory
  static unsigned char u[] = { 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r' };
  char b[100];
  memcpy (b, u, sizeof (u));
  b[sizeof (u)] = 0;
  foo (b);
#endif
}

void
testTortureExecute (void)
{
  qux ();
  bar ();
  baz ();
  return;
}