diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-11-13 09:44:20 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2024-11-13 09:44:20 +0100 |
commit | 856809e582bacbceb70cdae56feb86da367f379e (patch) | |
tree | cc311f08db7c3dfa52160e5047db450299f7d1ad /libcpp/expr.cc | |
parent | eb45d151fa1780d01533d9fc9545fec50bfd7152 (diff) | |
download | gcc-856809e582bacbceb70cdae56feb86da367f379e.zip gcc-856809e582bacbceb70cdae56feb86da367f379e.tar.gz gcc-856809e582bacbceb70cdae56feb86da367f379e.tar.bz2 |
c: Handle C23 floating constant {d,D}{32,64,128} suffixes like {df,dd,dl}
C23 roughly says that {d,D}{32,64,128} floating point constant suffixes
are alternate spellings of {df,dd,dl} suffixes in annex H.
So, the following patch allows that alternate spelling.
Or is it intentional it isn't enabled and we need to do everything in
there first before trying to define __STDC_IEC_60559_DFP__?
Like add support for _Decimal32x and _Decimal64x types (including
the d32x and d64x suffixes) etc.
2024-11-13 Jakub Jelinek <jakub@redhat.com>
libcpp/
* expr.cc (interpret_float_suffix): Handle d32 and D32 suffixes
for C like df, d64 and D64 like dd and d128 and D128 like
dl.
gcc/c-family/
* c-lex.cc (interpret_float): Subtract 3 or 4 from copylen
rather than 2 if last character of CPP_N_DFLOAT is a digit.
gcc/testsuite/
* gcc.dg/dfp/c11-constants-3.c: New test.
* gcc.dg/dfp/c11-constants-4.c: New test.
* gcc.dg/dfp/c23-constants-3.c: New test.
* gcc.dg/dfp/c23-constants-4.c: New test.
Diffstat (limited to 'libcpp/expr.cc')
-rw-r--r-- | libcpp/expr.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/libcpp/expr.cc b/libcpp/expr.cc index bbf21b8..6852337 100644 --- a/libcpp/expr.cc +++ b/libcpp/expr.cc @@ -99,9 +99,9 @@ interpret_float_suffix (cpp_reader *pfile, const uchar *s, size_t len) /* The following decimal float suffixes, from TR 24732:2009, TS 18661-2:2015 and C23, are supported: - df, DF - _Decimal32. - dd, DD - _Decimal64. - dl, DL - _Decimal128. + df, DF, d32, D32 - _Decimal32. + dd, DD, d64, D64 - _Decimal64. + dl, DL, d128, D128 - _Decimal128. The dN and DN suffixes for _DecimalN, and dNx and DNx for _DecimalNx, defined in TS 18661-3:2015, are not supported. @@ -253,7 +253,18 @@ interpret_float_suffix (cpp_reader *pfile, const uchar *s, size_t len) break; } return 0; - case 'd': case 'D': d++; break; + case 'd': case 'D': + if (!CPP_OPTION (pfile, cplusplus) && orig_s == s && len > 1) + { + if (s[1] == '3' && s[2] == '2' && len == 2) + return CPP_N_DFLOAT | CPP_N_SMALL; + if (s[1] == '6' && s[2] == '4' && len == 2) + return CPP_N_DFLOAT | CPP_N_MEDIUM; + if (s[1] == '1' && s[2] == '2' && len == 3 && s[3] == '8') + return CPP_N_DFLOAT | CPP_N_LARGE; + } + d++; + break; case 'l': case 'L': l++; break; case 'w': case 'W': w++; break; case 'q': case 'Q': q++; break; |