diff options
Diffstat (limited to 'gcc')
23 files changed, 538 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/c23-imaginary-constants-1.c b/gcc/testsuite/gcc.dg/c23-imaginary-constants-1.c new file mode 100644 index 0000000..afebc21 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-imaginary-constants-1.c @@ -0,0 +1,58 @@ +/* Test that imaginary constants are diagnosed in C23 mode: -pedantic. */ +/* { dg-do run } */ +/* { dg-options "-std=c23 -pedantic" } */ + +_Complex float a = 1.if; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex float b = 2.Fj; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex float c = 3.fI; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex float d = 4.JF; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex double e = 1.i; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex double f = 2.j; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex double g = 3.I; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex double h = 4.J; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex long double i = 1.il; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex long double j = 2.Lj; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex long double k = 3.lI; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex long double l = 4.JL; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +__extension__ _Complex float m = 1.if; +__extension__ _Complex float n = 2.Fj; +__extension__ _Complex float o = 3.fI; +__extension__ _Complex float p = 4.JF; +__extension__ _Complex double q = 1.i; +__extension__ _Complex double r = 2.j; +__extension__ _Complex double s = 3.I; +__extension__ _Complex double t = 4.J; +__extension__ _Complex long double u = 1.il; +__extension__ _Complex long double v = 2.Lj; +__extension__ _Complex long double w = 3.lI; +__extension__ _Complex long double x = 4.JL; + +int +main () +{ + if (a * a != -1.f + || b * b != -4.f + || c * c != -9.f + || d * d != -16.f + || e * e != -1. + || f * f != -4. + || g * g != -9. + || h * h != -16. + || i * i != -1.L + || j * j != -4.L + || k * k != -9.L + || l * l != -16.L + || m * m != -1.f + || n * n != -4.f + || o * o != -9.f + || p * p != -16.f + || q * q != -1. + || r * r != -4. + || s * s != -9. + || t * t != -16. + || u * u != -1.L + || v * v != -4.L + || w * w != -9.L + || x * x != -16.L) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/c23-imaginary-constants-10.c b/gcc/testsuite/gcc.dg/c23-imaginary-constants-10.c new file mode 100644 index 0000000..90165c1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-imaginary-constants-10.c @@ -0,0 +1,14 @@ +/* Test that imaginary constants are diagnosed in C23 mode: -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ +/* { dg-add-options float64x } */ +/* { dg-require-effective-target float64x } */ + +_Complex _Float64x a = 1.if64x; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64x b = 2.F64xj; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64x c = 3.f64xi; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64x d = 4.JF64x; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +__extension__ _Complex _Float64x e = 1.if64x; +__extension__ _Complex _Float64x f = 2.F64xj; +__extension__ _Complex _Float64x g = 3.f64xi; +__extension__ _Complex _Float64x h = 4.JF64x; diff --git a/gcc/testsuite/gcc.dg/c23-imaginary-constants-2.c b/gcc/testsuite/gcc.dg/c23-imaginary-constants-2.c new file mode 100644 index 0000000..4d23ff3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-imaginary-constants-2.c @@ -0,0 +1,28 @@ +/* Test that imaginary constants are diagnosed in C23 mode: -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ + +_Complex float a = 1.if; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex float b = 2.Fj; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex float c = 3.fI; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex float d = 4.JF; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex double e = 1.i; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex double f = 2.j; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex double g = 3.I; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex double h = 4.J; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex long double i = 1.il; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex long double j = 2.Lj; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex long double k = 3.lI; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex long double l = 4.JL; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +__extension__ _Complex float m = 1.if; +__extension__ _Complex float n = 2.Fj; +__extension__ _Complex float o = 3.fI; +__extension__ _Complex float p = 4.JF; +__extension__ _Complex double q = 1.i; +__extension__ _Complex double r = 2.j; +__extension__ _Complex double s = 3.I; +__extension__ _Complex double t = 4.J; +__extension__ _Complex long double u = 1.il; +__extension__ _Complex long double v = 2.Lj; +__extension__ _Complex long double w = 3.lI; +__extension__ _Complex long double x = 4.JL; diff --git a/gcc/testsuite/gcc.dg/c23-imaginary-constants-3.c b/gcc/testsuite/gcc.dg/c23-imaginary-constants-3.c new file mode 100644 index 0000000..ee003b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-imaginary-constants-3.c @@ -0,0 +1,64 @@ +/* Test that imaginary constants are diagnosed in C23 mode: -pedantic. */ +/* { dg-do run } */ +/* { dg-options "-std=c23 -pedantic" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32 } */ +/* { dg-require-effective-target float32x } */ +/* { dg-require-effective-target float64 } */ + +_Complex _Float32 a = 1.if32; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32 b = 2.F32j; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32 c = 3.f32i; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32 d = 4.JF32; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64 e = 1.if64; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64 f = 2.F64j; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64 g = 3.f64i; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64 h = 4.JF64; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32x i = 1.if32x; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32x j = 2.F32xj; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32x k = 3.f32xI; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32x l = 4.JF32x; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +__extension__ _Complex _Float32 m = 1.if32; +__extension__ _Complex _Float32 n = 2.F32j; +__extension__ _Complex _Float32 o = 3.f32i; +__extension__ _Complex _Float32 p = 4.JF32; +__extension__ _Complex _Float64 q = 1.if64; +__extension__ _Complex _Float64 r = 2.F64j; +__extension__ _Complex _Float64 s = 3.f64i; +__extension__ _Complex _Float64 t = 4.JF64; +__extension__ _Complex _Float32x u = 1.if32x; +__extension__ _Complex _Float32x v = 2.F32xj; +__extension__ _Complex _Float32x w = 3.f32xI; +__extension__ _Complex _Float32x x = 4.JF32x; + +int +main () +{ + if (a * a != -1.f32 + || b * b != -4.f32 + || c * c != -9.f32 + || d * d != -16.f32 + || e * e != -1.f64 + || f * f != -4.f64 + || g * g != -9.f64 + || h * h != -16.f64 + || i * i != -1.f32x + || j * j != -4.f32x + || k * k != -9.f32x + || l * l != -16.f32x + || m * m != -1.f32 + || n * n != -4.f32 + || o * o != -9.f32 + || p * p != -16.f32 + || q * q != -1.f64 + || r * r != -4.f64 + || s * s != -9.f64 + || t * t != -16.f64 + || u * u != -1.f32x + || v * v != -4.f32x + || w * w != -9.f32x + || x * x != -16.f32x) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/c23-imaginary-constants-4.c b/gcc/testsuite/gcc.dg/c23-imaginary-constants-4.c new file mode 100644 index 0000000..cdc51d5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-imaginary-constants-4.c @@ -0,0 +1,34 @@ +/* Test that imaginary constants are diagnosed in C23 mode: -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32 } */ +/* { dg-require-effective-target float32x } */ +/* { dg-require-effective-target float64 } */ + +_Complex _Float32 a = 1.if32; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32 b = 2.F32j; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32 c = 3.f32i; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32 d = 4.JF32; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64 e = 1.if64; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64 f = 2.F64j; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64 g = 3.f64i; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64 h = 4.JF64; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32x i = 1.if32x; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32x j = 2.F32xj; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32x k = 3.f32xI; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float32x l = 4.JF32x; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +__extension__ _Complex _Float32 m = 1.if32; +__extension__ _Complex _Float32 n = 2.F32j; +__extension__ _Complex _Float32 o = 3.f32i; +__extension__ _Complex _Float32 p = 4.JF32; +__extension__ _Complex _Float64 q = 1.if64; +__extension__ _Complex _Float64 r = 2.F64j; +__extension__ _Complex _Float64 s = 3.f64i; +__extension__ _Complex _Float64 t = 4.JF64; +__extension__ _Complex _Float32x u = 1.if32x; +__extension__ _Complex _Float32x v = 2.F32xj; +__extension__ _Complex _Float32x w = 3.f32xI; +__extension__ _Complex _Float32x x = 4.JF32x; diff --git a/gcc/testsuite/gcc.dg/c23-imaginary-constants-5.c b/gcc/testsuite/gcc.dg/c23-imaginary-constants-5.c new file mode 100644 index 0000000..82b5fbe --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-imaginary-constants-5.c @@ -0,0 +1,28 @@ +/* Test that imaginary constants are diagnosed in C23 mode: -pedantic. */ +/* { dg-do run } */ +/* { dg-options "-std=c23 -pedantic" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ + +_Complex _Float128 a = 1.if128; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float128 b = 2.F128j; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float128 c = 3.f128i; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float128 d = 4.JF128; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +__extension__ _Complex _Float128 e = 1.if128; +__extension__ _Complex _Float128 f = 2.F128j; +__extension__ _Complex _Float128 g = 3.f128i; +__extension__ _Complex _Float128 h = 4.JF128; + +int +main () +{ + if (a * a != -1.f128 + || b * b != -4.f128 + || c * c != -9.f128 + || d * d != -16.f128 + || e * e != -1.f128 + || f * f != -4.f128 + || g * g != -9.f128 + || h * h != -16.f128) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/c23-imaginary-constants-6.c b/gcc/testsuite/gcc.dg/c23-imaginary-constants-6.c new file mode 100644 index 0000000..7e9736d --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-imaginary-constants-6.c @@ -0,0 +1,14 @@ +/* Test that imaginary constants are diagnosed in C23 mode: -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ + +_Complex _Float128 a = 1.if128; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float128 b = 2.F128j; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float128 c = 3.f128i; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float128 d = 4.JF128; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +__extension__ _Complex _Float128 e = 1.if128; +__extension__ _Complex _Float128 f = 2.F128j; +__extension__ _Complex _Float128 g = 3.f128i; +__extension__ _Complex _Float128 h = 4.JF128; diff --git a/gcc/testsuite/gcc.dg/c23-imaginary-constants-7.c b/gcc/testsuite/gcc.dg/c23-imaginary-constants-7.c new file mode 100644 index 0000000..d5975f8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-imaginary-constants-7.c @@ -0,0 +1,28 @@ +/* Test that imaginary constants are diagnosed in C23 mode: -pedantic. */ +/* { dg-do run } */ +/* { dg-options "-std=c23 -pedantic" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +_Complex _Float16 a = 1.if16; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float16 b = 2.F16j; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float16 c = 3.f16i; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float16 d = 4.JF16; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +__extension__ _Complex _Float16 e = 1.if16; +__extension__ _Complex _Float16 f = 2.F16j; +__extension__ _Complex _Float16 g = 3.f16i; +__extension__ _Complex _Float16 h = 4.JF16; + +int +main () +{ + if (a * a != -1.f16 + || b * b != -4.f16 + || c * c != -9.f16 + || d * d != -16.f16 + || e * e != -1.f16 + || f * f != -4.f16 + || g * g != -9.f16 + || h * h != -16.f16) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/c23-imaginary-constants-8.c b/gcc/testsuite/gcc.dg/c23-imaginary-constants-8.c new file mode 100644 index 0000000..5539f2e --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-imaginary-constants-8.c @@ -0,0 +1,14 @@ +/* Test that imaginary constants are diagnosed in C23 mode: -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +_Complex _Float16 a = 1.if16; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float16 b = 2.F16j; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float16 c = 3.f16i; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float16 d = 4.JF16; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ +__extension__ _Complex _Float16 e = 1.if16; +__extension__ _Complex _Float16 f = 2.F16j; +__extension__ _Complex _Float16 g = 3.f16i; +__extension__ _Complex _Float16 h = 4.JF16; diff --git a/gcc/testsuite/gcc.dg/c23-imaginary-constants-9.c b/gcc/testsuite/gcc.dg/c23-imaginary-constants-9.c new file mode 100644 index 0000000..8b5a53d --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-imaginary-constants-9.c @@ -0,0 +1,28 @@ +/* Test that imaginary constants are diagnosed in C23 mode: -pedantic. */ +/* { dg-do run } */ +/* { dg-options "-std=c23 -pedantic" } */ +/* { dg-add-options float64x } */ +/* { dg-require-effective-target float64x } */ + +_Complex _Float64x a = 1.if64x; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64x b = 2.F64xj; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64x c = 3.f64xi; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +_Complex _Float64x d = 4.JF64x; /* { dg-warning "imaginary constants are a C2Y feature or GCC extension" } */ +__extension__ _Complex _Float64x e = 1.if64x; +__extension__ _Complex _Float64x f = 2.F64xj; +__extension__ _Complex _Float64x g = 3.f64xi; +__extension__ _Complex _Float64x h = 4.JF64x; + +int +main () +{ + if (a * a != -1.f64x + || b * b != -4.f64x + || c * c != -9.f64x + || d * d != -16.f64x + || e * e != -1.f64x + || f * f != -4.f64x + || g * g != -9.f64x + || h * h != -16.f64x) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-1.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-1.c new file mode 100644 index 0000000..8248f86 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-1.c @@ -0,0 +1,5 @@ +/* Test that imaginary constants are accepted in C2Y mode: -pedantic. */ +/* { dg-do run } */ +/* { dg-options "-std=c2y -pedantic" } */ + +#include "c23-imaginary-constants-1.c" diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-10.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-10.c new file mode 100644 index 0000000..2b93932 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-10.c @@ -0,0 +1,14 @@ +/* Test that imaginary constants are accepted in C2Y mode: compat warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -Wc23-c2y-compat" } */ +/* { dg-add-options float64x } */ +/* { dg-require-effective-target float64x } */ + +_Complex _Float64x a = 1.if64x; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float64x b = 2.F64xj; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float64x c = 3.f64xi; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float64x d = 4.JF64x; /* { dg-warning "imaginary constants are a C2Y feature" } */ +__extension__ _Complex _Float64x e = 1.if64x; +__extension__ _Complex _Float64x f = 2.F64xj; +__extension__ _Complex _Float64x g = 3.f64xi; +__extension__ _Complex _Float64x h = 4.JF64x; diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-11.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-11.c new file mode 100644 index 0000000..f3ca284 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-11.c @@ -0,0 +1,58 @@ +/* Test that integral imaginary constants are diagnosed in C2Y mode: -pedantic. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu2y -pedantic" } */ + +_Complex float a = 1i; /* { dg-warning "imaginary constants are a GCC extension" } */ +_Complex float b = 2j; /* { dg-warning "imaginary constants are a GCC extension" } */ +_Complex float c = 3I; /* { dg-warning "imaginary constants are a GCC extension" } */ +_Complex float d = 4J; /* { dg-warning "imaginary constants are a GCC extension" } */ +_Complex double e = 1il; /* { dg-warning "imaginary constants are a GCC extension" } */ +_Complex double f = 2Lj; /* { dg-warning "imaginary constants are a GCC extension" } */ +_Complex double g = 3lI; /* { dg-warning "imaginary constants are a GCC extension" } */ +_Complex double h = 4JL; /* { dg-warning "imaginary constants are a GCC extension" } */ +_Complex long double i = 1ill; /* { dg-warning "imaginary constants are a GCC extension" } */ +_Complex long double j = 2LLj; /* { dg-warning "imaginary constants are a GCC extension" } */ +_Complex long double k = 3llI; /* { dg-warning "imaginary constants are a GCC extension" } */ +_Complex long double l = 4JLL; /* { dg-warning "imaginary constants are a GCC extension" } */ +__extension__ _Complex float m = 1i; +__extension__ _Complex float n = 2j; +__extension__ _Complex float o = 3I; +__extension__ _Complex float p = 4J; +__extension__ _Complex double q = 1il; +__extension__ _Complex double r = 2Lj; +__extension__ _Complex double s = 3lI; +__extension__ _Complex double t = 4JL; +__extension__ _Complex long double u = 1ill; +__extension__ _Complex long double v = 2LLj; +__extension__ _Complex long double w = 3llI; +__extension__ _Complex long double x = 4JLL; + +int +main () +{ + if (a * a != -1.f + || b * b != -4.f + || c * c != -9.f + || d * d != -16.f + || e * e != -1. + || f * f != -4. + || g * g != -9. + || h * h != -16. + || i * i != -1.L + || j * j != -4.L + || k * k != -9.L + || l * l != -16.L + || m * m != -1.f + || n * n != -4.f + || o * o != -9.f + || p * p != -16.f + || q * q != -1. + || r * r != -4. + || s * s != -9. + || t * t != -16. + || u * u != -1.L + || v * v != -4.L + || w * w != -9.L + || x * x != -16.L) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-12.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-12.c new file mode 100644 index 0000000..4c42511 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-12.c @@ -0,0 +1,28 @@ +/* Test that integral imaginary constants are diagnosed in C2Y mode: -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2y -pedantic-errors" } */ + +_Complex float a = 1i; /* { dg-error "imaginary constants are a GCC extension" } */ +_Complex float b = 2j; /* { dg-error "imaginary constants are a GCC extension" } */ +_Complex float c = 3I; /* { dg-error "imaginary constants are a GCC extension" } */ +_Complex float d = 4J; /* { dg-error "imaginary constants are a GCC extension" } */ +_Complex double e = 1il; /* { dg-error "imaginary constants are a GCC extension" } */ +_Complex double f = 2Lj; /* { dg-error "imaginary constants are a GCC extension" } */ +_Complex double g = 3lI; /* { dg-error "imaginary constants are a GCC extension" } */ +_Complex double h = 4JL; /* { dg-error "imaginary constants are a GCC extension" } */ +_Complex long double i = 1ill; /* { dg-error "imaginary constants are a GCC extension" } */ +_Complex long double j = 2LLj; /* { dg-error "imaginary constants are a GCC extension" } */ +_Complex long double k = 3llI; /* { dg-error "imaginary constants are a GCC extension" } */ +_Complex long double l = 4JLL; /* { dg-error "imaginary constants are a GCC extension" } */ +__extension__ _Complex float m = 1i; +__extension__ _Complex float n = 2j; +__extension__ _Complex float o = 3I; +__extension__ _Complex float p = 4J; +__extension__ _Complex double q = 1il; +__extension__ _Complex double r = 2Lj; +__extension__ _Complex double s = 3lI; +__extension__ _Complex double t = 4JL; +__extension__ _Complex long double u = 1ill; +__extension__ _Complex long double v = 2LLj; +__extension__ _Complex long double w = 3llI; +__extension__ _Complex long double x = 4JLL; diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-2.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-2.c new file mode 100644 index 0000000..dd9350b --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-2.c @@ -0,0 +1,28 @@ +/* Test that imaginary constants are accepted in C2Y mode: compat warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -Wc23-c2y-compat" } */ + +_Complex float a = 1.if; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex float b = 2.Fj; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex float c = 3.fI; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex float d = 4.JF; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex double e = 1.i; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex double f = 2.j; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex double g = 3.I; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex double h = 4.J; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex long double i = 1.il; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex long double j = 2.Lj; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex long double k = 3.lI; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex long double l = 4.JL; /* { dg-warning "imaginary constants are a C2Y feature" } */ +__extension__ _Complex float m = 1.if; +__extension__ _Complex float n = 2.Fj; +__extension__ _Complex float o = 3.fI; +__extension__ _Complex float p = 4.JF; +__extension__ _Complex double q = 1.i; +__extension__ _Complex double r = 2.j; +__extension__ _Complex double s = 3.I; +__extension__ _Complex double t = 4.J; +__extension__ _Complex long double u = 1.il; +__extension__ _Complex long double v = 2.Lj; +__extension__ _Complex long double w = 3.lI; +__extension__ _Complex long double x = 4.JL; diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-3.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-3.c new file mode 100644 index 0000000..216380c --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-3.c @@ -0,0 +1,11 @@ +/* Test that imaginary constants are accepted in C2Y mode: -pedantic. */ +/* { dg-do run } */ +/* { dg-options "-std=c2y -pedantic" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32 } */ +/* { dg-require-effective-target float32x } */ +/* { dg-require-effective-target float64 } */ + +#include "c23-imaginary-constants-3.c" diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-4.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-4.c new file mode 100644 index 0000000..dc096fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-4.c @@ -0,0 +1,34 @@ +/* Test that imaginary constants are accepted in C2Y mode: compat warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -Wc23-c2y-compat" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32 } */ +/* { dg-require-effective-target float32x } */ +/* { dg-require-effective-target float64 } */ + +_Complex _Float32 a = 1.if32; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float32 b = 2.F32j; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float32 c = 3.f32i; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float32 d = 4.JF32; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float64 e = 1.if64; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float64 f = 2.F64j; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float64 g = 3.f64i; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float64 h = 4.JF64; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float32x i = 1.if32x; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float32x j = 2.F32xj; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float32x k = 3.f32xI; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float32x l = 4.JF32x; /* { dg-warning "imaginary constants are a C2Y feature" } */ +__extension__ _Complex _Float32 m = 1.if32; +__extension__ _Complex _Float32 n = 2.F32j; +__extension__ _Complex _Float32 o = 3.f32i; +__extension__ _Complex _Float32 p = 4.JF32; +__extension__ _Complex _Float64 q = 1.if64; +__extension__ _Complex _Float64 r = 2.F64j; +__extension__ _Complex _Float64 s = 3.f64i; +__extension__ _Complex _Float64 t = 4.JF64; +__extension__ _Complex _Float32x u = 1.if32x; +__extension__ _Complex _Float32x v = 2.F32xj; +__extension__ _Complex _Float32x w = 3.f32xI; +__extension__ _Complex _Float32x x = 4.JF32x; diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-5.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-5.c new file mode 100644 index 0000000..4e9ceaf --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-5.c @@ -0,0 +1,7 @@ +/* Test that imaginary constants are accepted in C2Y mode: -pedantic. */ +/* { dg-do run } */ +/* { dg-options "-std=c2y -pedantic" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ + +#include "c23-imaginary-constants-5.c" diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-6.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-6.c new file mode 100644 index 0000000..2654fba --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-6.c @@ -0,0 +1,14 @@ +/* Test that imaginary constants are accepted in C2Y mode: compat warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -Wc23-c2y-compat" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ + +_Complex _Float128 a = 1.if128; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float128 b = 2.F128j; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float128 c = 3.f128i; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float128 d = 4.JF128; /* { dg-warning "imaginary constants are a C2Y feature" } */ +__extension__ _Complex _Float128 e = 1.if128; +__extension__ _Complex _Float128 f = 2.F128j; +__extension__ _Complex _Float128 g = 3.f128i; +__extension__ _Complex _Float128 h = 4.JF128; diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-7.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-7.c new file mode 100644 index 0000000..b31eba9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-7.c @@ -0,0 +1,7 @@ +/* Test that imaginary constants are accepted in C2Y mode: -pedantic. */ +/* { dg-do run } */ +/* { dg-options "-std=c2y -pedantic" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +#include "c23-imaginary-constants-7.c" diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-8.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-8.c new file mode 100644 index 0000000..cf603df --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-8.c @@ -0,0 +1,14 @@ +/* Test that imaginary constants are accepted in C2Y mode: compat warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -Wc23-c2y-compat" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +_Complex _Float16 a = 1.if16; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float16 b = 2.F16j; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float16 c = 3.f16i; /* { dg-warning "imaginary constants are a C2Y feature" } */ +_Complex _Float16 d = 4.JF16; /* { dg-warning "imaginary constants are a C2Y feature" } */ +__extension__ _Complex _Float16 e = 1.if16; +__extension__ _Complex _Float16 f = 2.F16j; +__extension__ _Complex _Float16 g = 3.f16i; +__extension__ _Complex _Float16 h = 4.JF16; diff --git a/gcc/testsuite/gcc.dg/c2y-imaginary-constants-9.c b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-9.c new file mode 100644 index 0000000..02c1beb --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-imaginary-constants-9.c @@ -0,0 +1,7 @@ +/* Test that imaginary constants are accepted in C2Y mode: -pedantic. */ +/* { dg-do run } */ +/* { dg-options "-std=c2y -pedantic" } */ +/* { dg-add-options float64x } */ +/* { dg-require-effective-target float64x } */ + +#include "c23-imaginary-constants-9.c" diff --git a/gcc/testsuite/gcc.dg/cpp/pr7263-3.c b/gcc/testsuite/gcc.dg/cpp/pr7263-3.c index 225b659..84a4231 100644 --- a/gcc/testsuite/gcc.dg/cpp/pr7263-3.c +++ b/gcc/testsuite/gcc.dg/cpp/pr7263-3.c @@ -15,5 +15,5 @@ bar2 () __complex__ bar3 () /* { dg-error "ISO C does not support plain .complex. meaning .double complex." } */ { - return _Complex_I; /* { dg-error "imaginary constants are a GCC extension" } */ + return _Complex_I; /* { dg-error "imaginary constants are a C2Y feature or GCC extension" } */ } |