[clang] [BitInt] Expose a _BitInt literal suffix in C++ (PR #86586)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 9 12:01:32 PDT 2024


================
@@ -1117,6 +1118,26 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
       if (isImaginary) break;   // Cannot be repeated.
       isImaginary = true;
       continue;  // Success.
+    case '_':
+      if (isFPConstant)
+        break; // Invalid for floats
+      if (HasSize)
+        break;
+      if (PossibleBitInt)
+        break; // Cannot be repeated.
+      if (LangOpts.CPlusPlus && s + 1 < ThisTokEnd && s[1] == '_') {
+        // Scan ahead to find possible rest of BitInt suffix
+        for (const char *c = s; c != ThisTokEnd; ++c) {
+          if (*c == 'w' || *c == 'W') {
----------------
AaronBallman wrote:

We definitely should not allow `__iwb` because that puts the `i` suffix in the middle of the `__wb` suffix. However, because we accept `iwb` or `wbi` in C, I think it's reasonable to support `i__wb` or `__wbi` in C++: https://godbolt.org/z/nb9d9qWKK

https://github.com/llvm/llvm-project/pull/86586


More information about the cfe-commits mailing list