builtin-fpclassification.c
2.91 KB
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
// RUN: %clang_cc1 %s -Wno-unused-value -verify -fsyntax-only
// RUN: %clang_cc1 %s -Wno-unused-value -ast-dump -DAST_CHECK | FileCheck %s
struct S {};
void usage(float f, int i, double d) {
#ifdef AST_CHECK
__builtin_fpclassify(d, 1, i, i, 3, d);
//CHECK: CallExpr
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: <BuiltinFnToFnPtr>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: '__builtin_fpclassify'
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'int' <FloatingToIntegral>
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'double' <LValueToRValue>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: 'd' 'double'
//CHECK-NEXT: IntegerLiteral
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'int' <LValueToRValue>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: 'i' 'int'
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'int' <LValueToRValue>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: 'i' 'int'
//CHECK-NEXT: IntegerLiteral
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'double' <LValueToRValue>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: 'd' 'double'
__builtin_fpclassify(f, 1, i, i, 3, f);
//CHECK: CallExpr
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: <BuiltinFnToFnPtr>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: '__builtin_fpclassify'
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'int' <FloatingToIntegral>
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'float' <LValueToRValue>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: 'f' 'float'
//CHECK-NEXT: IntegerLiteral
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'int' <LValueToRValue>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: 'i' 'int'
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'int' <LValueToRValue>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: 'i' 'int'
//CHECK-NEXT: IntegerLiteral
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'float' <LValueToRValue>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: 'f' 'float'
__builtin_isfinite(f);
//CHECK: CallExpr
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: <BuiltinFnToFnPtr>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: '__builtin_isfinite'
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'float' <LValueToRValue>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: 'f' 'float'
__builtin_isfinite(d);
//CHECK: CallExpr
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: <BuiltinFnToFnPtr>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: '__builtin_isfinite'
//CHECK-NEXT: ImplicitCastExpr
//CHECK-SAME: 'double' <LValueToRValue>
//CHECK-NEXT: DeclRefExpr
//CHECK-SAME: 'd' 'double'
#else
struct S s;
// expected-error@+1{{passing 'struct S' to parameter of incompatible type 'int'}}
__builtin_fpclassify(d, s, i, i, 3, d);
// expected-error@+1{{floating point classification requires argument of floating point type (passed in 'int')}}
__builtin_fpclassify(d, 1, i, i, 3, i);
// expected-error@+1{{floating point classification requires argument of floating point type (passed in 'int')}}
__builtin_isfinite(i);
#endif
}