diff options
Diffstat (limited to 'libcpp/expr.cc')
-rw-r--r-- | libcpp/expr.cc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/libcpp/expr.cc b/libcpp/expr.cc index 1d68064..5ee28c4 100644 --- a/libcpp/expr.cc +++ b/libcpp/expr.cc @@ -91,10 +91,10 @@ interpret_float_suffix (cpp_reader *pfile, const uchar *s, size_t len) size_t orig_len = len; const uchar *orig_s = s; size_t flags; - size_t f, d, l, w, q, i, fn, fnx, fn_bits; + size_t f, d, l, w, q, i, fn, fnx, fn_bits, bf16; flags = 0; - f = d = l = w = q = i = fn = fnx = fn_bits = 0; + f = d = l = w = q = i = fn = fnx = fn_bits = bf16 = 0; /* The following decimal float suffixes, from TR 24732:2009, TS 18661-2:2015 and C2X, are supported: @@ -131,7 +131,8 @@ interpret_float_suffix (cpp_reader *pfile, const uchar *s, size_t len) w, W - machine-specific type such as __float80 (GNU extension). q, Q - machine-specific type such as __float128 (GNU extension). fN, FN - _FloatN (TS 18661-3:2015). - fNx, FNx - _FloatNx (TS 18661-3:2015). */ + fNx, FNx - _FloatNx (TS 18661-3:2015). + bf16, BF16 - std::bfloat16_t (ISO C++23). */ /* Process decimal float suffixes, which are two letters starting with d or D. Order and case are significant. */ @@ -239,6 +240,19 @@ interpret_float_suffix (cpp_reader *pfile, const uchar *s, size_t len) fn++; } break; + case 'b': case 'B': + if (len > 2 + /* Except for bf16 / BF16 where case is significant. */ + && s[1] == (s[0] == 'b' ? 'f' : 'F') + && s[2] == '1' + && s[3] == '6') + { + bf16++; + len -= 3; + s += 3; + break; + } + return 0; case 'd': case 'D': d++; break; case 'l': case 'L': l++; break; case 'w': case 'W': w++; break; @@ -257,7 +271,7 @@ interpret_float_suffix (cpp_reader *pfile, const uchar *s, size_t len) of N larger than can be represented in the return value. The caller is responsible for rejecting _FloatN suffixes where _FloatN is not supported on the chosen target. */ - if (f + d + l + w + q + fn + fnx > 1 || i > 1) + if (f + d + l + w + q + fn + fnx + bf16 > 1 || i > 1) return 0; if (fn_bits > CPP_FLOATN_MAX) return 0; @@ -295,6 +309,7 @@ interpret_float_suffix (cpp_reader *pfile, const uchar *s, size_t len) q ? CPP_N_MD_Q : fn ? CPP_N_FLOATN | (fn_bits << CPP_FLOATN_SHIFT) : fnx ? CPP_N_FLOATNX | (fn_bits << CPP_FLOATN_SHIFT) : + bf16 ? CPP_N_BFLOAT16 : CPP_N_DEFAULT)); } |