[PATCH] D57577: Make predefined FLT16 macros conditional on support for the type
Nemanja Ivanovic via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 1 03:25:45 PST 2019
nemanjai created this revision.
nemanjai added reviewers: rogfer01, bruno, ahatanak, scanon.
Herald added subscribers: aheejin, jgravelle-google, sbc100, dschuff.
Herald added a project: clang.
We unconditionally predefine these macros. However, they may be used to determine if the type is supported. In that case, there are unnecessary failures to compile the code.
This is the proposed fix for https://bugs.llvm.org/show_bug.cgi?id=40559
Repository:
rC Clang
https://reviews.llvm.org/D57577
Files:
lib/Basic/Targets/WebAssembly.h
lib/Frontend/InitPreprocessor.cpp
test/Headers/float16.c
Index: test/Headers/float16.c
===================================================================
--- test/Headers/float16.c
+++ test/Headers/float16.c
@@ -1,7 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -x c++ -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c89 \
+// RUN: -ffreestanding %s
+// RUN: %clang_cc1 -triple=wasm64-unknown-unknown -fsyntax-only -verify \
+// RUN: -std=c99 -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c11 \
+// RUN: -ffreestanding %s
+// RUN: %clang_cc1 -triple=wasm64-unknown-unknown -fsyntax-only -verify \
+// RUN: -std=c++11 -x c++ -ffreestanding %s
// expected-no-diagnostics
#define __STDC_WANT_IEC_60559_TYPES_EXT__
Index: lib/Frontend/InitPreprocessor.cpp
===================================================================
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -830,7 +830,8 @@
DefineFmt("__UINTPTR", TI.getUIntPtrType(), TI, Builder);
DefineTypeWidth("__UINTPTR_WIDTH__", TI.getUIntPtrType(), TI, Builder);
- DefineFloatMacros(Builder, "FLT16", &TI.getHalfFormat(), "F16");
+ if (TI.hasFloat16Type())
+ DefineFloatMacros(Builder, "FLT16", &TI.getHalfFormat(), "F16");
DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F");
DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), "");
DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L");
Index: lib/Basic/Targets/WebAssembly.h
===================================================================
--- lib/Basic/Targets/WebAssembly.h
+++ lib/Basic/Targets/WebAssembly.h
@@ -52,6 +52,7 @@
SizeType = UnsignedLong;
PtrDiffType = SignedLong;
IntPtrType = SignedLong;
+ HasFloat16 = true;
}
protected:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57577.184716.patch
Type: text/x-patch
Size: 2019 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190201/8ad37b11/attachment-0001.bin>
More information about the cfe-commits
mailing list