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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 06:54:36 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] == '_') {
----------------
AaronBallman wrote:

I think you might be remembering this comment:
```
  // This routine assumes that the range begin/end matches the regex for integer
  // and FP constants (specifically, the 'pp-number' regex), and assumes that
  // the byte at "*end" is both valid and not part of the regex.  Because of
  // this, it doesn't have to check for 'overscan' in various places.
  // Note: For HLSL, the end token is allowed to be '.' which would be in the
  // 'pp-number' regex. This is required to support vector swizzles on numeric
  // constants (i.e. 1.xx or 1.5f.rrr).
```
but I took that to be about pp-number and not the suffix (suffixes are not part of pp-number because suffixes are about types and the preprocessor is type-agnostic).

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


More information about the cfe-commits mailing list