|
| 1 | +// RUN: %clang_cc1 -verify=ped -std=c23 -Wall -pedantic %s |
| 2 | +// RUN: %clang_cc1 -verify=yay -std=c2y -Wall -pedantic %s |
| 3 | +// RUN: %clang_cc1 -verify=pre -std=c2y -Wpre-c2y-compat -Wall -pedantic %s |
| 4 | +// RUN: %clang_cc1 -verify=gnu -Wall -Wgnu -x c++ %s |
| 5 | +// RUN: %clang_cc1 -verify=yay -Wall -Wgnu -Wno-gnu-imaginary-constant -x c++ %s |
| 6 | + |
| 7 | + |
| 8 | +/* WG14 N3298: Yes |
| 9 | + * Introduce complex literals v. 2 |
| 10 | + * |
| 11 | + * This introduces two suffixes for making complex literals: i and j (and I and |
| 12 | + * J), which can be combined in any order with the other floating literal |
| 13 | + * suffixes. |
| 14 | + * |
| 15 | + * We support these suffixes in older language modes as a conforming extension. |
| 16 | + * It used to be a GNU extension, but now it's a C2y extension. |
| 17 | + */ |
| 18 | + |
| 19 | +// yay-no-diagnostics |
| 20 | + |
| 21 | +static_assert(_Generic(12.0i, _Complex double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 22 | + ped-warning {{imaginary constants are a C2y extension}} |
| 23 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 24 | + */ |
| 25 | +static_assert(_Generic(12.0fi, _Complex float : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 26 | + ped-warning {{imaginary constants are a C2y extension}} |
| 27 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 28 | + */ |
| 29 | +static_assert(_Generic(12.0li, _Complex long double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 30 | + ped-warning {{imaginary constants are a C2y extension}} |
| 31 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 32 | + */ |
| 33 | +static_assert(_Generic(12.0if, _Complex float : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 34 | + ped-warning {{imaginary constants are a C2y extension}} |
| 35 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 36 | + */ |
| 37 | +static_assert(_Generic(12.0il, _Complex long double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 38 | + ped-warning {{imaginary constants are a C2y extension}} |
| 39 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 40 | + */ |
| 41 | + |
| 42 | +static_assert(_Generic(12.0I, _Complex double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 43 | + ped-warning {{imaginary constants are a C2y extension}} |
| 44 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 45 | + */ |
| 46 | +static_assert(_Generic(12.0fI, _Complex float : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 47 | + ped-warning {{imaginary constants are a C2y extension}} |
| 48 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 49 | + */ |
| 50 | +static_assert(_Generic(12.0lI, _Complex long double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 51 | + ped-warning {{imaginary constants are a C2y extension}} |
| 52 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 53 | + */ |
| 54 | +static_assert(_Generic(12.0If, _Complex float : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 55 | + ped-warning {{imaginary constants are a C2y extension}} |
| 56 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 57 | + */ |
| 58 | +static_assert(_Generic(12.0Il, _Complex long double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 59 | + ped-warning {{imaginary constants are a C2y extension}} |
| 60 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 61 | + */ |
| 62 | + |
| 63 | +static_assert(_Generic(12.0j, _Complex double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 64 | + ped-warning {{imaginary constants are a C2y extension}} |
| 65 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 66 | + */ |
| 67 | +static_assert(_Generic(12.0fj, _Complex float : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 68 | + ped-warning {{imaginary constants are a C2y extension}} |
| 69 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 70 | + */ |
| 71 | +static_assert(_Generic(12.0lj, _Complex long double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 72 | + ped-warning {{imaginary constants are a C2y extension}} |
| 73 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 74 | + */ |
| 75 | +static_assert(_Generic(12.0jf, _Complex float : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 76 | + ped-warning {{imaginary constants are a C2y extension}} |
| 77 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 78 | + */ |
| 79 | +static_assert(_Generic(12.0jl, _Complex long double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 80 | + ped-warning {{imaginary constants are a C2y extension}} |
| 81 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 82 | + */ |
| 83 | + |
| 84 | +static_assert(_Generic(12.0J, _Complex double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 85 | + ped-warning {{imaginary constants are a C2y extension}} |
| 86 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 87 | + */ |
| 88 | +static_assert(_Generic(12.0fJ, _Complex float : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 89 | + ped-warning {{imaginary constants are a C2y extension}} |
| 90 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 91 | + */ |
| 92 | +static_assert(_Generic(12.0lJ, _Complex long double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 93 | + ped-warning {{imaginary constants are a C2y extension}} |
| 94 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 95 | + */ |
| 96 | +static_assert(_Generic(12.0Jf, _Complex float : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 97 | + ped-warning {{imaginary constants are a C2y extension}} |
| 98 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 99 | + */ |
| 100 | +static_assert(_Generic(12.0Jl, _Complex long double : 1, default : 0)); /* gnu-warning {{imaginary constants are a GNU extension}} |
| 101 | + ped-warning {{imaginary constants are a C2y extension}} |
| 102 | + pre-warning {{imaginary constants are incompatible with C standards before C2y}} |
| 103 | + */ |
| 104 | + |
0 commit comments