| 1 |
// RUN: %clang_cc1 -verify -std=c99 -ffreestanding %s |
| 2 |
// RUN: %clang_cc1 -verify -std=gnu89 -ffreestanding %s |
| 3 |
// RUN: %clang_cc1 -verify -std=c89 -ffreestanding %s |
| 4 |
// expected-no-diagnostics |
| 5 |
|
| 6 |
/* WG14 ???: Clang 16 |
| 7 |
* Additional floating-point characteristics in <float.h> |
| 8 |
* |
| 9 |
* NB: the original paper number is unknown, this was gleaned from the editor's |
| 10 |
* report in the C99 foreword. There were two new additions to <float.h> in |
| 11 |
* C99, this is testing that we support both of them. |
| 12 |
* |
| 13 |
* Clang added the macros at least as far back as Clang 3.0, but it wasn't |
| 14 |
* until Clang 16.0 that we stopped accidentally providing FLT_EVAL_METHOD in |
| 15 |
* C89 (strict) mode. |
| 16 |
*/ |
| 17 |
|
| 18 |
#include <float.h> |
| 19 |
|
| 20 |
// We expect all the definitions in C99 mode. |
| 21 |
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L |
| 22 |
#define EXPECT_DECIMAL_DIG |
| 23 |
#define EXPECT_FLT_EVAL_METHOD |
| 24 |
#endif |
| 25 |
|
| 26 |
// If we're not in C99 mode, we still expect the definition of DECIMAL_DIG |
| 27 |
// unless we're in strict ansi mode. |
| 28 |
#if !defined(EXPECT_DECIMAL_DIG) && !defined(__STRICT_ANSI__) |
| 29 |
#define EXPECT_DECIMAL_DIG |
| 30 |
#endif |
| 31 |
|
| 32 |
#if defined(EXPECT_DECIMAL_DIG) |
| 33 |
#if !defined(DECIMAL_DIG) |
| 34 |
#error "DECIMAL_DIG missing" |
| 35 |
#endif |
| 36 |
#else |
| 37 |
#if defined(DECIMAL_DIG) |
| 38 |
#error "DECIMAL_DIG provided when not expected" |
| 39 |
#endif |
| 40 |
#endif |
| 41 |
|
| 42 |
#if defined(EXPECT_FLT_EVAL_METHOD) |
| 43 |
#if !defined(FLT_EVAL_METHOD) |
| 44 |
#error "FLT_EVAL_METHOD missing" |
| 45 |
#endif |
| 46 |
#else |
| 47 |
#if defined(FLT_EVAL_METHOD) |
| 48 |
#error "FLT_EVAL_METHOD provided when not expected" |
| 49 |
#endif |
| 50 |
#endif |