mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-22 03:46:53 -05:00
The following patch implements the C2Y N3298 paper Introduce complex literals by providing different (or no) diagnostics on imaginary constants (except for integer ones). For _DecimalN constants we don't support _Complex _DecimalN and error on any i/j suffixes mixed with DD/DL/DF, so nothing changed there. 2024-11-13 Jakub Jelinek <jakub@redhat.com> PR c/117029 libcpp/ * include/cpplib.h (struct cpp_options): Add imaginary_constants member. * init.cc (struct lang_flags): Add imaginary_constants bitfield. (lang_defaults): Add column for imaginary_constants. (cpp_set_lang): Copy over imaginary_constants. * expr.cc (cpp_classify_number): Diagnose CPP_N_IMAGINARY non-CPP_N_FLOATING constants differently for C. gcc/testsuite/ * gcc.dg/cpp/pr7263-3.c: Adjust expected diagnostic wording. * gcc.dg/c23-imaginary-constants-1.c: New test. * gcc.dg/c23-imaginary-constants-2.c: New test. * gcc.dg/c23-imaginary-constants-3.c: New test. * gcc.dg/c23-imaginary-constants-4.c: New test. * gcc.dg/c23-imaginary-constants-5.c: New test. * gcc.dg/c23-imaginary-constants-6.c: New test. * gcc.dg/c23-imaginary-constants-7.c: New test. * gcc.dg/c23-imaginary-constants-8.c: New test. * gcc.dg/c23-imaginary-constants-9.c: New test. * gcc.dg/c23-imaginary-constants-10.c: New test. * gcc.dg/c2y-imaginary-constants-1.c: New test. * gcc.dg/c2y-imaginary-constants-2.c: New test. * gcc.dg/c2y-imaginary-constants-3.c: New test. * gcc.dg/c2y-imaginary-constants-4.c: New test. * gcc.dg/c2y-imaginary-constants-5.c: New test. * gcc.dg/c2y-imaginary-constants-6.c: New test. * gcc.dg/c2y-imaginary-constants-7.c: New test. * gcc.dg/c2y-imaginary-constants-8.c: New test. * gcc.dg/c2y-imaginary-constants-9.c: New test. * gcc.dg/c2y-imaginary-constants-10.c: New test. * gcc.dg/c2y-imaginary-constants-11.c: New test. * gcc.dg/c2y-imaginary-constants-12.c: New test.
29 lines
1.7 KiB
C
29 lines
1.7 KiB
C
/* 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;
|