105 lines · c
1// RUN: %clang_cc1 -verify=ped -std=c23 -Wall -pedantic %s2// RUN: %clang_cc1 -verify=yay -std=c2y -Wall -pedantic %s3// RUN: %clang_cc1 -verify=pre -std=c2y -Wpre-c2y-compat -Wall -pedantic %s4// RUN: %clang_cc1 -verify=gnu -Wall -Wgnu -x c++ %s5// RUN: %clang_cc1 -verify=yay -Wall -Wgnu -Wno-gnu-imaginary-constant -x c++ %s6 7 8/* WG14 N3298: Yes9 * Introduce complex literals v. 210 *11 * This introduces two suffixes for making complex literals: i and j (and I and12 * J), which can be combined in any order with the other floating literal13 * 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-diagnostics20 21static_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 */25static_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 */29static_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 */33static_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 */37static_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 42static_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 */46static_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 */50static_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 */54static_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 */58static_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 63static_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 */67static_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 */71static_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 */75static_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 */79static_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 84static_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 */88static_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 */92static_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 */96static_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 */100static_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 105