summaryrefslogtreecommitdiff
path: root/support/regression/tests/gcc-torture-execute-20050125-1.c
blob: 1ca1a9a4bb18fc341d37fa4582cf661210ce0036 (plain) (blame)
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
/*
   20050125-1.c from the execute part of the gcc torture suite.
 */

#include <testfwk.h>

#ifdef __SDCC
#pragma std_c99
#endif

/* Verify that the CALL side effect isn't optimized away.  */
/* Contributed by Greg Parker  25 Jan 2005  <gparker@apple.com> */

#include <stdlib.h>
#include <stdio.h>

struct parse {
  char *next;
  char *end;
  int error;
};

int seterr(struct parse *p, int err)
{
  p->error = err;
  return 0;
}

void bracket_empty(struct parse *p)
{
  if (((p->next < p->end) && (*p->next++) == ']')  ||  seterr(p, 7)) { }
}

void testTortureExecute(void)
{
  struct parse p;
  char x;
  p.next = p.end = &x;

  p.error = 0;
  bracket_empty(&p);
  if (p.error != 7)
    ASSERT (0);

  return;
}