r352229 - Remove F16 literal support based on Float16 support.

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 25 10:36:21 PST 2019


Author: erichkeane
Date: Fri Jan 25 10:36:20 2019
New Revision: 352229

URL: http://llvm.org/viewvc/llvm-project?rev=352229&view=rev
Log:
Remove F16 literal support based on Float16 support.

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

Added:
    cfe/trunk/test/SemaCXX/Float16.cpp   (with props)
Modified:
    cfe/trunk/lib/Lex/LiteralSupport.cpp

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=352229&r1=352228&r2=352229&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Fri Jan 25 10:36:20 2019
@@ -616,10 +616,11 @@ NumericLiteralParser::NumericLiteralPars
       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;

Added: cfe/trunk/test/SemaCXX/Float16.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/Float16.cpp?rev=352229&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/Float16.cpp (added)
+++ cfe/trunk/test/SemaCXX/Float16.cpp Fri Jan 25 10:36:20 2019
@@ -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 at +2{{_Float16 is not supported on this target}}
+#endif // !HAVE
+_Float16 f;
+
+#ifndef HAVE
+// expected-error at +2{{invalid suffix 'F16' on floating constant}}
+#endif // !HAVE
+const auto g = 1.1F16;

Propchange: cfe/trunk/test/SemaCXX/Float16.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/SemaCXX/Float16.cpp
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Rev URL"

Propchange: cfe/trunk/test/SemaCXX/Float16.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the cfe-commits mailing list