| 1 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s |
| 2 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s -fexperimental-new-constant-interpreter |
| 3 |
|
| 4 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP -DNOERROR %s |
| 5 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP -DNOERROR %s -fexperimental-new-constant-interpreter |
| 6 |
|
| 7 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \ |
| 8 |
// RUN: -ffp-eval-method=source -DNOERROR %s |
| 9 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \ |
| 10 |
// RUN: -ffp-eval-method=source -DNOERROR %s -fexperimental-new-constant-interpreter |
| 11 |
|
| 12 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \ |
| 13 |
// RUN: -ffp-eval-method=source \ |
| 14 |
// RUN: -DNOERROR %s |
| 15 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \ |
| 16 |
// RUN: -ffp-eval-method=source \ |
| 17 |
// RUN: -DNOERROR %s -fexperimental-new-constant-interpreter |
| 18 |
|
| 19 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \ |
| 20 |
// RUN: -ffp-eval-method=double %s |
| 21 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \ |
| 22 |
// RUN: -ffp-eval-method=double %s -fexperimental-new-constant-interpreter |
| 23 |
|
| 24 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \ |
| 25 |
// RUN: -ffp-eval-method=double %s |
| 26 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \ |
| 27 |
// RUN: -ffp-eval-method=double %s -fexperimental-new-constant-interpreter |
| 28 |
|
| 29 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \ |
| 30 |
// RUN: -ffp-eval-method=extended %s |
| 31 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \ |
| 32 |
// RUN: -ffp-eval-method=extended %s -fexperimental-new-constant-interpreter |
| 33 |
|
| 34 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \ |
| 35 |
// RUN: -ffp-eval-method=extended %s |
| 36 |
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \ |
| 37 |
// RUN: -ffp-eval-method=extended %s -fexperimental-new-constant-interpreter |
| 38 |
|
| 39 |
#ifdef NOERROR |
| 40 |
// expected-no-diagnostics |
| 41 |
typedef float float_t; |
| 42 |
typedef double double_t; |
| 43 |
#else |
| 44 |
#ifdef CPP |
| 45 |
typedef float float_t; //expected-error 9 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}} |
| 46 |
|
| 47 |
typedef double double_t; //expected-error 9 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}} |
| 48 |
#else |
| 49 |
typedef float float_t; //expected-error 7 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}} |
| 50 |
|
| 51 |
typedef double double_t; //expected-error 7 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}} |
| 52 |
#endif |
| 53 |
#endif |
| 54 |
|
| 55 |
float foo1() { |
| 56 |
#pragma clang fp eval_method(source) |
| 57 |
float a; |
| 58 |
double b; |
| 59 |
return a - b; |
| 60 |
} |
| 61 |
|
| 62 |
float foo2() { |
| 63 |
#pragma clang fp eval_method(source) |
| 64 |
float_t a; |
| 65 |
double_t b; |
| 66 |
return a - b; |
| 67 |
} |
| 68 |
|
| 69 |
void foo3() { |
| 70 |
#pragma clang fp eval_method(source) |
| 71 |
char buff[sizeof(float_t)]; |
| 72 |
char bufd[sizeof(double_t)]; |
| 73 |
buff[1] = bufd[2]; |
| 74 |
} |
| 75 |
|
| 76 |
float foo4() { |
| 77 |
#pragma clang fp eval_method(source) |
| 78 |
typedef float_t FT; |
| 79 |
typedef double_t DT; |
| 80 |
FT a; |
| 81 |
DT b; |
| 82 |
return a - b; |
| 83 |
} |
| 84 |
|
| 85 |
int foo5() { |
| 86 |
#pragma clang fp eval_method(source) |
| 87 |
int t = _Generic( 1.0L, float_t:1, default:0); |
| 88 |
int v = _Generic( 1.0L, double_t:1, default:0); |
| 89 |
return t; |
| 90 |
} |
| 91 |
|
| 92 |
void foo6() { |
| 93 |
#pragma clang fp eval_method(source) |
| 94 |
float f = (float_t)1; |
| 95 |
double d = (double_t)2; |
| 96 |
} |
| 97 |
|
| 98 |
void foo7() { |
| 99 |
#pragma clang fp eval_method(source) |
| 100 |
float c1 = (float_t)12; |
| 101 |
double c2 = (double_t)13; |
| 102 |
} |
| 103 |
|
| 104 |
float foo8() { |
| 105 |
#pragma clang fp eval_method(source) |
| 106 |
extern float_t f; |
| 107 |
extern double_t g; |
| 108 |
return f-g; |
| 109 |
} |
| 110 |
|
| 111 |
#ifdef CPP |
| 112 |
void foo9() { |
| 113 |
#pragma clang fp eval_method(source) |
| 114 |
auto resf = [](float_t f) { return f; }; |
| 115 |
auto resd = [](double_t g) { return g; }; |
| 116 |
} |
| 117 |
|
| 118 |
void foo10() { |
| 119 |
#pragma clang fp eval_method(source) |
| 120 |
using Ft = float_t; |
| 121 |
using Dt = double_t; |
| 122 |
Ft a; |
| 123 |
Dt b; |
| 124 |
} |
| 125 |
#endif |