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

#include <testfwk.h>

#ifdef __SDCC
#pragma std_c99
#endif

/* PR c/37924 */


signed char a;
unsigned char b;

#if !(defined (__GNUC__) && defined (__GNUC_MINOR__) && (__GNUC__ < 5 && __GNUC_MINOR__ < 4))
int
ftest1 (void)
{
  int c = -1;
  return ((unsigned int) (a ^ c)) >> 9;
}

int
ftest2 (void)
{
  int c = -1;
  return ((unsigned int) (b ^ c)) >> 9;
}
#endif

void
testTortureExecute (void)
{
#if !(defined (__GNUC__) && defined (__GNUC_MINOR__) && (__GNUC__ < 5 && __GNUC_MINOR__ < 4))
  a = 0;
  if (ftest1 () != (-1U >> 9))
    ASSERT (0);
  a = 0x40;
  if (ftest1 () != (-1U >> 9))
    ASSERT (0);
  a = 0x80;
  if (ftest1 () != (a < 0) ? 0 : (-1U >> 9))
    ASSERT (0);
  a = 0xff;
  if (ftest1 () != (a < 0) ? 0 : (-1U >> 9))
    ASSERT (0);
  b = 0;
  if (ftest2 () != (-1U >> 9))
    ASSERT (0);
  b = 0x40;
  if (ftest2 () != (-1U >> 9))
    ASSERT (0);
  b = 0x80;
  if (ftest2 () != (-1U >> 9))
    ASSERT (0);
  b = 0xff;
  if (ftest2 () != (-1U >> 9))
    ASSERT (0);
  return;
#endif
}