summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/floatn-arithconv.c
blob: c3eb24e1fcd1dc53212f07b72e27fb5dc2ab0378 (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
/* Tests for _FloatN / _FloatNx types: test usual arithmetic
   conversions.  */
/* { dg-do compile } */
/* { dg-options "" } */
/* { dg-add-options float32 } */
/* { dg-add-options float64 } */
/* { dg-add-options float32x } */
/* { dg-require-effective-target float32 } */
/* { dg-require-effective-target float64 } */
/* { dg-require-effective-target float32x } */

#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>

int i;

#define TEST(VAR, TYPE1, TYPE2, RESTYPE)			\
  do								\
    {								\
      typedef __typeof__ ((TYPE1) 0 + (TYPE2) 1) restype;	\
      typedef __typeof__ (i ? (TYPE1) 0 : (TYPE2) 1) restype2;	\
      typedef RESTYPE exptype;					\
      extern restype VAR;					\
      extern restype2 VAR;					\
      extern exptype VAR;					\
    }								\
  while (0)

void
f (void)
{
  TEST (v1, float, double, double);
#if DBL_MANT_DIG > FLT32_MANT_DIG
  TEST (v2, double, _Float32, double);
#endif
#if DBL_MANT_DIG <= FLT64_MANT_DIG
  TEST (v3, double, _Float64, _Float64);
#endif
#if DBL_MANT_DIG >= FLT32X_MANT_DIG
  TEST (v4, double, _Float32x, double);
#endif
#if FLT_MANT_DIG <= FLT32_MANT_DIG
  TEST (v5, float, _Float32, _Float32);
#endif
#if FLT32X_MANT_DIG <= FLT64_MANT_DIG
  TEST (v6, _Float32x, _Float64, _Float64);
#endif
  TEST (v7, _Float32, _Float64, _Float64);
  TEST (v8, _Float32, _Float32x, _Float32x);
}