51 lines · c
1// RUN: %clang_cc1 -verify -std=c99 -ffreestanding %s2// RUN: %clang_cc1 -verify -std=gnu89 -ffreestanding %s3// RUN: %clang_cc1 -verify -std=c89 -ffreestanding %s4// expected-no-diagnostics5 6/* WG14 ???: Clang 167 * Additional floating-point characteristics in <float.h>8 *9 * NB: the original paper number is unknown, this was gleaned from the editor's10 * report in the C99 foreword. There were two new additions to <float.h> in11 * 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't14 * until Clang 16.0 that we stopped accidentally providing FLT_EVAL_METHOD in15 * 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__ >= 199901L22#define EXPECT_DECIMAL_DIG23#define EXPECT_FLT_EVAL_METHOD24#endif25 26// If we're not in C99 mode, we still expect the definition of DECIMAL_DIG27// unless we're in strict ansi mode.28#if !defined(EXPECT_DECIMAL_DIG) && !defined(__STRICT_ANSI__)29#define EXPECT_DECIMAL_DIG30#endif31 32#if defined(EXPECT_DECIMAL_DIG)33 #if !defined(DECIMAL_DIG)34 #error "DECIMAL_DIG missing"35 #endif36#else37 #if defined(DECIMAL_DIG)38 #error "DECIMAL_DIG provided when not expected"39 #endif40#endif41 42#if defined(EXPECT_FLT_EVAL_METHOD)43 #if !defined(FLT_EVAL_METHOD)44 #error "FLT_EVAL_METHOD missing"45 #endif46#else47 #if defined(FLT_EVAL_METHOD)48 #error "FLT_EVAL_METHOD provided when not expected"49 #endif50#endif51