[Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL
authorPirama Arumuga Nainar <pirama@google.com>
Wed, 8 Aug 2018 20:38:38 +0000 (20:38 +0000)
committerPirama Arumuga Nainar <pirama@google.com>
Wed, 8 Aug 2018 20:38:38 +0000 (20:38 +0000)
Summary:
These macros are defined in the C11 standard and can be defined based on
the __*_HAS_DENORM__ default macros.

Reviewers: bruno, rsmith, doug.gregor

Subscribers: llvm-commits, enh, srhines

Differential Revision: https://reviews.llvm.org/D37302

llvm-svn: 339284

clang/lib/Headers/float.h
clang/test/Headers/float.c

index c04cbbf..56215cd 100644 (file)
@@ -85,6 +85,9 @@
 #    undef FLT_DECIMAL_DIG
 #    undef DBL_DECIMAL_DIG
 #    undef LDBL_DECIMAL_DIG
+#    undef FLT_HAS_SUBNORM
+#    undef DBL_HAS_SUBNORM
+#    undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
index 46e9cc3..74ebb84 100644 (file)
     #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
         #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
     #endif
+    #ifndef FLT_HAS_SUBNORM
+        #error "Mandatory macro FLT_HAS_SUBNORM is missing."
+    #elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+        #error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+    #endif
+    #ifndef LDBL_HAS_SUBNORM
+        #error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+    #elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+        #error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+    #endif
+    #ifndef DBL_HAS_SUBNORM
+        #error "Mandatory macro DBL_HAS_SUBNORM is missing."
+    #elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+        #error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+    #endif
 #else
     #ifdef FLT_DECIMAL_DIG
         #error "Macro FLT_DECIMAL_DIG should not be defined."
     #ifdef LDBL_DECIMAL_DIG
         #error "Macro LDBL_DECIMAL_DIG should not be defined."
     #endif
+    #ifdef FLT_HAS_SUBNORM
+        #error "Macro FLT_HAS_SUBNORM should not be defined."
+    #endif
+    #ifdef DBL_HAS_SUBNORM
+        #error "Macro DBL_HAS_SUBNORM should not be defined."
+    #endif
+    #ifdef LDBL_HAS_SUBNORM
+        #error "Macro LDBL_HAS_SUBNORM should not be defined."
+    #endif
 #endif