]> git.ipfire.org Git - thirdparty/gcc.git/commit
Support decimal floating-point constants in C2x.
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Oct 2019 22:22:52 +0000 (22:22 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Oct 2019 22:22:52 +0000 (22:22 +0000)
commit488ec13ac9a4728438b2abbd6ddc11b34edc19a9
tree298edc1e58a374a72a21832169c07cd2157bcb8b
parent707aa069296cd42f27d1b53b38205b163c64af3f
Support decimal floating-point constants in C2x.

ISO C2x adds decimal floating point as an optional standard feature.
This patch accordingly makes GCC accept DFP constants (DF, DD, DL, df,
dd, dl suffixes) in strict C2X mode, with a pedwarn-if-pedantic for
older standards and a warning with -Wc11-c2x-compat even in C2x mode
(which in turn requires -Wc11-c2x-compat to be newly passed through to
libcpp).

Bootstrapped with no regressions on x86_64-pc-linux-gnu.

gcc/c-family:
* c.opt (Wc11-c2x-compat): Add CPP(cpp_warn_c11_c2x_compat)
CppReason(CPP_W_C11_C2X_COMPAT).

gcc/testsuite:
* gcc.dg/dfp/c11-constants-1.c, gcc.dg/dfp/c11-constants-2.c,
gcc.dg/dfp/c2x-constants-1.c, gcc.dg/dfp/c2x-constants-2.c: New
tests.
* gcc.dg/dfp/constants-pedantic.c: Use -std=gnu17 explicitly.
Update expected diagnostics.

libcpp:
* include/cpplib.h (struct cpp_options): Add dfp_constants and
cpp_warn_c11_c2x_compat.
(enum cpp_warning_reason): Add CPP_W_C11_C2X_COMPAT.
* init.c (struct lang_flags): Add dfp_constants.
(lang_defaults): Set dfp_constants to 1 for GNUC2X and STDC2X and
0 for other languages.
(cpp_set_lang): Set dfp_constants from language.
(cpp_create_reader): Set cpp_warn_c11_c2x_compat to -1.
* expr.c (interpret_float_suffix): Mention DFP constants as C2X in
comment.
(cpp_classify_number): Do not diagnose DFP constants for languages
setting dfp_constants, unless cpp_warn_c11_c2x_compat.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@276908 138bc75d-0d04-0410-961f-82ee72b054a4
12 files changed:
gcc/c-family/ChangeLog
gcc/c-family/c.opt
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/dfp/c11-constants-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/c11-constants-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/c2x-constants-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/c2x-constants-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/constants-pedantic.c
libcpp/ChangeLog
libcpp/expr.c
libcpp/include/cpplib.h
libcpp/init.c