[clang] [BitInt] Expose a _BitInt literal suffix in C++ (PR #86586)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 26 10:15:29 PDT 2024
================
@@ -1117,19 +1118,37 @@ 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] == '_') {
+ // Scan ahead to find possible rest of BitInt suffix
+ for (const char *c = s; c != ThisTokEnd; ++c) {
+ if (*c == 'w' || *c == 'W') {
+ possibleBitInt = true;
+ ++s;
----------------
AaronBallman wrote:
Not necessary -- because it's undefined behavior, we're not breaking anything, the code was already broken to begin with. Also, users already get a reasonable diagnostic on the declaration of the UDL:
```
warning: user-defined literal suffixes containing '__' are reserved; no literal will invoke this operator [-Wuser-defined-literals]
1 | unsigned operator ""__w(const char *);
```
https://github.com/llvm/llvm-project/pull/86586
More information about the cfe-commits
mailing list