summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/20050121-1.c
blob: 9d5dec416421792e8e9d6afb850fa1b3e256d820 (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
/* PR middle-end/19551 */

extern void abort ();

#define T(type, name) \
__attribute__((pure)) _Complex type		\
foo_##name (int x)				\
{						\
  _Complex type r;				\
  __real r = x + 1;				\
  __imag r = x - 1;				\
  return r;					\
}						\
						\
void						\
bar_##name (type *x)				\
{						\
  *x = __real foo_##name (5);			\
}						\
						\
void						\
baz_##name (type *x)				\
{						\
  *x = __imag foo_##name (5);			\
}

typedef long double ldouble_t;
typedef long long llong;

T (float, float)
T (double, double)
T (long double, ldouble_t)
T (char, char)
T (short, short)
T (int, int)
T (long, long)
T (long long, llong)
#undef T

int
main (void)
{
#define T(type, name) \
  {						\
    type var = 0;				\
    bar_##name (&var);				\
    if (var != 6)				\
      abort ();					\
    var = 0;					\
    baz_##name (&var);				\
    if (var != 4)				\
      abort ();					\
  }
  T (float, float)
  T (double, double)
  T (long double, ldouble_t)
  T (char, char)
  T (short, short)
  T (int, int)
  T (long, long)
  T (long long, llong)
  return 0;
}