[clang] f619868 - [C99] Claim conformance to "additional floating-point characteristics in <float.h>"

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 2 09:15:35 PDT 2024


Author: Aaron Ballman
Date: 2024-04-02T12:15:10-04:00
New Revision: f6198686b866d0a1efe7ce88f71c4293930c2dfe

URL: https://github.com/llvm/llvm-project/commit/f6198686b866d0a1efe7ce88f71c4293930c2dfe
DIFF: https://github.com/llvm/llvm-project/commit/f6198686b866d0a1efe7ce88f71c4293930c2dfe.diff

LOG: [C99] Claim conformance to "additional floating-point characteristics in <float.h>"

This is another case where we don't have a paper number for the feature
but know about it from the editor's reports.

Added: 
    clang/test/C/C99/float_h-characteristics.c

Modified: 
    clang/www/c_status.html

Removed: 
    


################################################################################
diff  --git a/clang/test/C/C99/float_h-characteristics.c b/clang/test/C/C99/float_h-characteristics.c
new file mode 100644
index 00000000000000..7e2a891ef87774
--- /dev/null
+++ b/clang/test/C/C99/float_h-characteristics.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -verify -std=c99 -ffreestanding %s
+// RUN: %clang_cc1 -verify -std=gnu89 -ffreestanding %s
+// RUN: %clang_cc1 -verify -std=c89 -ffreestanding %s
+// expected-no-diagnostics
+
+/* WG14 ???: Clang 16
+ * Additional floating-point characteristics in <float.h>
+ *
+ * NB: the original paper number is unknown, this was gleaned from the editor's
+ * report in the C99 foreword. There were two new additions to <float.h> in
+ * C99, this is testing that we support both of them.
+ *
+ * Clang added the macros at least as far back as Clang 3.0, but it wasn't
+ * until Clang 16.0 that we stopped accidentally providing FLT_EVAL_METHOD in
+ * C89 (strict) mode.
+ */
+
+#include <float.h>
+
+// We expect all the definitions in C99 mode.
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define EXPECT_DECIMAL_DIG
+#define EXPECT_FLT_EVAL_METHOD
+#endif
+
+// If we're not in C99 mode, we still expect the definition of DECIMAL_DIG
+// unless we're in strict ansi mode.
+#if !defined(EXPECT_DECIMAL_DIG) && !defined(__STRICT_ANSI__)
+#define EXPECT_DECIMAL_DIG
+#endif
+
+#if defined(EXPECT_DECIMAL_DIG)
+  #if !defined(DECIMAL_DIG)
+    #error "DECIMAL_DIG missing"
+  #endif
+#else
+  #if defined(DECIMAL_DIG)
+    #error "DECIMAL_DIG provided when not expected"
+  #endif
+#endif
+
+#if defined(EXPECT_FLT_EVAL_METHOD)
+  #if !defined(FLT_EVAL_METHOD)
+    #error "FLT_EVAL_METHOD missing"
+  #endif
+#else
+  #if defined(FLT_EVAL_METHOD)
+    #error "FLT_EVAL_METHOD provided when not expected"
+  #endif
+#endif

diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index 803dce8e29fc04..43f7a5e7602b38 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -173,7 +173,7 @@ <h2 id="c99">C99 implementation status</h2>
     <tr>
       <td>additional floating-point characteristics in <float.h></td>
       <td>Unknown</td>
-      <td class="unknown" align="center">Unknown</td>
+      <td class="full" align="center">Clang 16</td>
     </tr>
     <tr id="implicit int">
       <td rowspan="4">remove implicit int</td>


        


More information about the cfe-commits mailing list