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

#include <testfwk.h>

#ifdef __SDCC
#pragma std_c99
#endif


/* Checks that pure functions are not treated as const.  */

const char *p;

static int
is_end_of_statement (void)
{
  return *p == '\n' || *p == ';' || *p == '!';
}

void foo (void)
{
  /* The is_end_of_statement call was moved out of the loop at one stage,
     resulting in an endless loop.  */
  while (!is_end_of_statement ())
    p++;
}

void
testTortureExecute (void)
{
  p = "abc\n";
  foo ();
  return;
}