File: float_h-characteristics.c

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (50 lines) | stat: -rw-r--r-- 1,497 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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