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

#include <testfwk.h>

#ifdef __SDCC
#pragma std_c99
#endif

// TODO: Enable when sdcc supports long long in these ports!
#if !defined(__SDCC_pic14) && !defined(__SDCC_pic16)

unsigned
f1 (int x)
{
  return ((unsigned) (x != 0) - 3) / 2;
}

unsigned long long
f2 (int x)
{
  return ((unsigned long long) (x != 0) - 3) / 2;
}
#endif

void
testTortureExecute (void)
{
#if !defined(__SDCC_pic14) && !defined(__SDCC_pic16)
  if (f1 (1) != (~(unsigned) 0) >> 1)
    ASSERT (0);
  if (f1 (0) != ((~(unsigned) 0) >> 1) - 1)
    ASSERT (0);
  if (f2 (1) != (~(unsigned long long) 0) >> 1)
    ASSERT (0);
  if (f2 (0) != ((~(unsigned long long) 0) >> 1) - 1)
    ASSERT (0);
  return;
#endif
}