OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [builtins/] [complex-1.c] - Blame information for rev 688

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
/* Test for builtin conj, creal, cimag.  */
2
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
3
 
4
extern float _Complex conjf (float _Complex);
5
extern double _Complex conj (double _Complex);
6
extern long double _Complex conjl (long double _Complex);
7
 
8
extern float crealf (float _Complex);
9
extern double creal (double _Complex);
10
extern long double creall (long double _Complex);
11
 
12
extern float cimagf (float _Complex);
13
extern double cimag (double _Complex);
14
extern long double cimagl (long double _Complex);
15
 
16
extern void abort (void);
17
extern void link_error (void);
18
 
19
void
20
main_test (void)
21
{
22
  /* For each type, test both runtime and compile time (constant folding)
23
     optimization.  */
24
  volatile float _Complex fc = 1.0F + 2.0iF;
25
  volatile double _Complex dc = 1.0 + 2.0i;
26
  volatile long double _Complex ldc = 1.0L + 2.0iL;
27
  /* Test floats.  */
28
  if (conjf (fc) != 1.0F - 2.0iF)
29
    abort ();
30
  if (__builtin_conjf (fc) != 1.0F - 2.0iF)
31
    abort ();
32
  if (conjf (1.0F + 2.0iF) != 1.0F - 2.0iF)
33
    link_error ();
34
  if (__builtin_conjf (1.0F + 2.0iF) != 1.0F - 2.0iF)
35
    link_error ();
36
  if (crealf (fc) != 1.0F)
37
    abort ();
38
  if (__builtin_crealf (fc) != 1.0F)
39
    abort ();
40
  if (crealf (1.0F + 2.0iF) != 1.0F)
41
    link_error ();
42
  if (__builtin_crealf (1.0F + 2.0iF) != 1.0F)
43
    link_error ();
44
  if (cimagf (fc) != 2.0F)
45
    abort ();
46
  if (__builtin_cimagf (fc) != 2.0F)
47
    abort ();
48
  if (cimagf (1.0F + 2.0iF) != 2.0F)
49
    link_error ();
50
  if (__builtin_cimagf (1.0F + 2.0iF) != 2.0F)
51
    link_error ();
52
  /* Test doubles.  */
53
  if (conj (dc) != 1.0 - 2.0i)
54
    abort ();
55
  if (__builtin_conj (dc) != 1.0 - 2.0i)
56
    abort ();
57
  if (conj (1.0 + 2.0i) != 1.0 - 2.0i)
58
    link_error ();
59
  if (__builtin_conj (1.0 + 2.0i) != 1.0 - 2.0i)
60
    link_error ();
61
  if (creal (dc) != 1.0)
62
    abort ();
63
  if (__builtin_creal (dc) != 1.0)
64
    abort ();
65
  if (creal (1.0 + 2.0i) != 1.0)
66
    link_error ();
67
  if (__builtin_creal (1.0 + 2.0i) != 1.0)
68
    link_error ();
69
  if (cimag (dc) != 2.0)
70
    abort ();
71
  if (__builtin_cimag (dc) != 2.0)
72
    abort ();
73
  if (cimag (1.0 + 2.0i) != 2.0)
74
    link_error ();
75
  if (__builtin_cimag (1.0 + 2.0i) != 2.0)
76
    link_error ();
77
  /* Test long doubles.  */
78
  if (conjl (ldc) != 1.0L - 2.0iL)
79
    abort ();
80
  if (__builtin_conjl (ldc) != 1.0L - 2.0iL)
81
    abort ();
82
  if (conjl (1.0L + 2.0iL) != 1.0L - 2.0iL)
83
    link_error ();
84
  if (__builtin_conjl (1.0L + 2.0iL) != 1.0L - 2.0iL)
85
    link_error ();
86
  if (creall (ldc) != 1.0L)
87
    abort ();
88
  if (__builtin_creall (ldc) != 1.0L)
89
    abort ();
90
  if (creall (1.0L + 2.0iL) != 1.0L)
91
    link_error ();
92
  if (__builtin_creall (1.0L + 2.0iL) != 1.0L)
93
    link_error ();
94
  if (cimagl (ldc) != 2.0L)
95
    abort ();
96
  if (__builtin_cimagl (ldc) != 2.0L)
97
    abort ();
98
  if (cimagl (1.0L + 2.0iL) != 2.0L)
99
    link_error ();
100
  if (__builtin_cimagl (1.0L + 2.0iL) != 2.0L)
101
    link_error ();
102
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.