[PATCH] D99456: [C++2b] Support size_t literals

Anton Bikineev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 29 19:13:26 PDT 2021


AntonBikineev marked 7 inline comments as done.
AntonBikineev added a comment.

Thanks Richard for taking a look!



================
Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:190
   InGroup<CXX98CompatPedantic>, DefaultIgnore;
+def ext_cxx2b_size_t_suffix : Extension<
+  "'size_t' suffix for literals is a C++2b extension">,
----------------
rsmith wrote:
> Should this be an `ExtWarn`? I think we should warn on this by default.
I tried to follow the strategy used for 'long long' (only warn with -Wlong-long), but I agree that warn-by-default would probably be better.


================
Comment at: clang/lib/Lex/LiteralSupport.cpp:594-595
 
   // Loop over all of the characters of the suffix.  If we see something bad,
   // we break out of the loop.
   for (; s != ThisTokEnd; ++s) {
----------------
rsmith wrote:
> General comment: I think the checks here have become too complex and error-prone. I suggest we add another flag, `hasSize`, that's set when we parse any size modifier (`F`, `L`, `LL`, `H`, `F128`, `I64`, and now `Z`), and when parsing any size modifier, replace the existing ad-hoc set of checks with a check for `hasSize`.
Good idea! It actually helped to flush out the issue when Q and H are mixed together: https://godbolt.org/z/8hj39P93a


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99456/new/

https://reviews.llvm.org/D99456



More information about the cfe-commits mailing list