]> granicus.if.org Git - clang/commitdiff
Remove F16 literal support based on Float16 support.
authorErich Keane <erich.keane@intel.com>
Fri, 25 Jan 2019 18:36:20 +0000 (18:36 +0000)
committerErich Keane <erich.keane@intel.com>
Fri, 25 Jan 2019 18:36:20 +0000 (18:36 +0000)
Float16 support was disabled recently on many platforms, however that
commit still allowed literals of Float16 type to work.  This commit
removes those based on the same logic as Float16 disable.

Change-Id: I72243048ae2db3dc47bd3d699843e3edf9c395ea

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352229 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/LiteralSupport.cpp
test/SemaCXX/Float16.cpp [new file with mode: 0644]

index 834c80780d14e3e1fa08e7f3c542b239033f0011..b9ee3190f567c794a3ca418170aa292f5035bbe1 100644 (file)
@@ -616,10 +616,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
       if (isHalf || isFloat || isLong || isFloat128)
         break; // HF, FF, LF, QF invalid.
 
-      if (s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') {
-          s += 2; // success, eat up 2 characters.
-          isFloat16 = true;
-          continue;
+      if (PP.getTargetInfo().hasFloat16Type() && s + 2 < ThisTokEnd &&
+          s[1] == '1' && s[2] == '6') {
+        s += 2; // success, eat up 2 characters.
+        isFloat16 = true;
+        continue;
       }
 
       isFloat = true;
diff --git a/test/SemaCXX/Float16.cpp b/test/SemaCXX/Float16.cpp
new file mode 100644 (file)
index 0000000..f27c383
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s -DHAVE
+// RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE
+// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE
+
+#ifdef HAVE
+// expected-no-diagnostics
+#endif // HAVE
+
+#ifndef HAVE
+// expected-error@+2{{_Float16 is not supported on this target}}
+#endif // !HAVE
+_Float16 f;
+
+#ifndef HAVE
+// expected-error@+2{{invalid suffix 'F16' on floating constant}}
+#endif // !HAVE
+const auto g = 1.1F16;