blob: d58a36dc108ae49dcef8785736ecb88b98f48807 (
plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
// RUN: -x c++ -DCPP -DNOERROR %s
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
// RUN: -x c++ -DCPP -DNOERROR %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
// RUN: -ffp-eval-method=extended -DNOERROR %s
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
// RUN: -ffp-eval-method=extended -DNOERROR %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
// RUN: -ffp-eval-method=extended -DNOERROR %s
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
// RUN: -ffp-eval-method=extended -DNOERROR %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
// RUN: -ffp-eval-method=source %s
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
// RUN: -ffp-eval-method=source %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
// RUN: -ffp-eval-method=source %s
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
// RUN: -ffp-eval-method=source %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
// RUN: -ffp-eval-method=double %s
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
// RUN: -ffp-eval-method=double %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
// RUN: -ffp-eval-method=double %s
// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
// RUN: -ffp-eval-method=double %s -fexperimental-new-constant-interpreter
#ifdef NOERROR
// expected-no-diagnostics
typedef float float_t;
typedef double double_t;
#else
#ifdef CPP
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}}
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}}
#else
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}}
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}}
#endif
#endif
float foo1() {
#pragma clang fp eval_method(extended)
float a;
double b;
return a - b;
}
float foo2() {
#pragma clang fp eval_method(extended)
float_t a;
double_t b;
return a - b;
}
void foo3() {
#pragma clang fp eval_method(extended)
char buff[sizeof(float_t)];
char bufd[sizeof(double_t)];
buff[1] = bufd[2];
}
float foo4() {
#pragma clang fp eval_method(extended)
typedef float_t FT;
typedef double_t DT;
FT a;
DT b;
return a - b;
}
int foo5() {
#pragma clang fp eval_method(extended)
int t = _Generic( 1.0L, float_t:1, default:0);
int v = _Generic( 1.0L, double_t:1, default:0);
return t;
}
void foo6() {
#pragma clang fp eval_method(extended)
float f = (float_t)1;
double d = (double_t)2;
}
void foo7() {
#pragma clang fp eval_method(extended)
float c1 = (float_t)12;
double c2 = (double_t)13;
}
float foo8() {
#pragma clang fp eval_method(extended)
extern float_t f;
extern double_t g;
return f-g;
}
#ifdef CPP
void foo9() {
#pragma clang fp eval_method(extended)
auto resf = [](float_t f) { return f; };
auto resd = [](double_t g) { return g; };
}
void foo10() {
#pragma clang fp eval_method(extended)
using Ft = float_t;
using Dt = double_t;
Ft a;
Dt b;
}
#endif
|