[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 7 10:43:26 PDT 2025


================
@@ -978,6 +979,24 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
   // we break out of the loop.
   for (; s != ThisTokEnd; ++s) {
     switch (*s) {
+    case 'b': // FP Suffix for "__bf16"
+    case 'B':
+      if (!Target.hasBFloat16Type())
+        break;
+      if (!isFPConstant)
+        break; // Error for integer constant.
+      if (HasSize)
+        break;
+      HasSize = true;
+
+      if (s + 3 < ThisTokEnd &&
+          ((s[0] == 'b' && s[1] == 'f') || (s[0] == 'B' && s[1] == 'F')) &&
+          s[2] == '1' && s[3] == '6') {
+        s += 3; // success, eat up 3 characters.
+        isBFloat16 = true;
+        continue;
+      }
+      break;
----------------
AaronBallman wrote:

Yes, we should have extension warnings in other language modes

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


More information about the cfe-commits mailing list