]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/c2x-constexpr-9.c
1 /* Test C23 constexpr. Invalid code, compilation tests, IEEE arithmetic. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c23 -pedantic-errors" } */
4 /* { dg-add-options ieee } */
5 /* { dg-require-effective-target inff } */
7 /* A conversion from signaling NaN to quiet NaN in a different format or type
8 is not valid for constexpr. */
9 constexpr float fns
= __builtin_nans (""); /* { dg-error "'constexpr' initializer not representable in type of object" } */
10 constexpr double dns
= __builtin_nansf (""); /* { dg-error "'constexpr' initializer not representable in type of object" } */
11 constexpr long double ldns
= __builtin_nans (""); /* { dg-error "'constexpr' initializer not representable in type of object" } */
13 /* Test out-of-range values. */
14 constexpr float fu
= __DBL_MIN__
; /* { dg-error "'constexpr' initializer not representable in type of object" } */
15 constexpr float fo
= __DBL_MAX__
; /* { dg-error "'constexpr' initializer not representable in type of object" } */
16 constexpr float fp
= 0x1.ffffffp0
; /* { dg-error "'constexpr' initializer not representable in type of object" } */
18 constexpr _Complex
float cfur
= __builtin_complex (__DBL_MIN__
, 0.0); /* { dg-error "'constexpr' initializer not representable in type of object" } */
19 constexpr _Complex
float cfor
= __builtin_complex (__DBL_MAX__
, 0.0); /* { dg-error "'constexpr' initializer not representable in type of object" } */
20 constexpr _Complex
float cfpr
= __builtin_complex (0x1.ffffffp0
, 0.0); /* { dg-error "'constexpr' initializer not representable in type of object" } */
22 constexpr _Complex
float cfui
= __builtin_complex (0.0, __DBL_MIN__
); /* { dg-error "'constexpr' initializer not representable in type of object" } */
23 constexpr _Complex
float cfoi
= __builtin_complex (0.0, __DBL_MAX__
); /* { dg-error "'constexpr' initializer not representable in type of object" } */
24 constexpr _Complex
float cfpi
= __builtin_complex (0.0, 0x1.ffffffp0
); /* { dg-error "'constexpr' initializer not representable in type of object" } */
26 constexpr _Complex
float cfd
= __DBL_MAX__
; /* { dg-error "'constexpr' initializer not representable in type of object" } */
27 constexpr _Complex
float cfi
= __LONG_LONG_MAX__
; /* { dg-error "'constexpr' initializer not representable in type of object" } */
32 (constexpr float) { __builtin_nans ("") }; /* { dg-error "'constexpr' initializer not representable in type of object" } */
33 (constexpr double) { __builtin_nansf ("") }; /* { dg-error "'constexpr' initializer not representable in type of object" } */
34 (constexpr float) { __DBL_MIN__
}; /* { dg-error "'constexpr' initializer not representable in type of object" } */
35 (constexpr float) { __DBL_MAX__
}; /* { dg-error "'constexpr' initializer not representable in type of object" } */
36 (constexpr float) { 0x1.ffffffp0
}; /* { dg-error "'constexpr' initializer not representable in type of object" } */
37 (constexpr _Complex
float) { __builtin_complex (__DBL_MIN__
, 0.0) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */
38 (constexpr _Complex
float) { __builtin_complex (__DBL_MAX__
, 0.0) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */
39 (constexpr _Complex
float) { __builtin_complex (0x1.ffffffp0
, 0.0) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */
40 (constexpr _Complex
float) { __builtin_complex (0.0, __DBL_MIN__
) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */
41 (constexpr _Complex
float) { __builtin_complex (0.0, __DBL_MAX__
) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */
42 (constexpr _Complex
float) { __builtin_complex (0.0, 0x1.ffffffp0
) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */
43 (constexpr _Complex
float) { __DBL_MAX__
}; /* { dg-error "'constexpr' initializer not representable in type of object" } */
44 (constexpr _Complex
float) { __LONG_LONG_MAX__
}; /* { dg-error "'constexpr' initializer not representable in type of object" } */