[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / builtin-fpclassification.c
blob83e248bfd1b5f8997c1e09f917a1f60abe0d6e77
1 // RUN: %clang_cc1 %s -Wno-unused-value -verify -fsyntax-only
2 // RUN: %clang_cc1 %s -Wno-unused-value -ast-dump -DAST_CHECK | FileCheck %s
4 struct S {};
5 void usage(float f, int i, double d) {
6 #ifdef AST_CHECK
7 __builtin_fpclassify(d, 1, i, i, 3, d);
8 //CHECK: CallExpr
9 //CHECK-NEXT: ImplicitCastExpr
10 //CHECK-SAME: <BuiltinFnToFnPtr>
11 //CHECK-NEXT: DeclRefExpr
12 //CHECK-SAME: '__builtin_fpclassify'
13 //CHECK-NEXT: ImplicitCastExpr
14 //CHECK-SAME: 'int' <FloatingToIntegral>
15 //CHECK-NEXT: ImplicitCastExpr
16 //CHECK-SAME: 'double' <LValueToRValue>
17 //CHECK-NEXT: DeclRefExpr
18 //CHECK-SAME: 'd' 'double'
19 //CHECK-NEXT: IntegerLiteral
20 //CHECK-NEXT: ImplicitCastExpr
21 //CHECK-SAME: 'int' <LValueToRValue>
22 //CHECK-NEXT: DeclRefExpr
23 //CHECK-SAME: 'i' 'int'
24 //CHECK-NEXT: ImplicitCastExpr
25 //CHECK-SAME: 'int' <LValueToRValue>
26 //CHECK-NEXT: DeclRefExpr
27 //CHECK-SAME: 'i' 'int'
28 //CHECK-NEXT: IntegerLiteral
29 //CHECK-NEXT: ImplicitCastExpr
30 //CHECK-SAME: 'double' <LValueToRValue>
31 //CHECK-NEXT: DeclRefExpr
32 //CHECK-SAME: 'd' 'double'
34 __builtin_fpclassify(f, 1, i, i, 3, f);
35 //CHECK: CallExpr
36 //CHECK-NEXT: ImplicitCastExpr
37 //CHECK-SAME: <BuiltinFnToFnPtr>
38 //CHECK-NEXT: DeclRefExpr
39 //CHECK-SAME: '__builtin_fpclassify'
40 //CHECK-NEXT: ImplicitCastExpr
41 //CHECK-SAME: 'int' <FloatingToIntegral>
42 //CHECK-NEXT: ImplicitCastExpr
43 //CHECK-SAME: 'float' <LValueToRValue>
44 //CHECK-NEXT: DeclRefExpr
45 //CHECK-SAME: 'f' 'float'
46 //CHECK-NEXT: IntegerLiteral
47 //CHECK-NEXT: ImplicitCastExpr
48 //CHECK-SAME: 'int' <LValueToRValue>
49 //CHECK-NEXT: DeclRefExpr
50 //CHECK-SAME: 'i' 'int'
51 //CHECK-NEXT: ImplicitCastExpr
52 //CHECK-SAME: 'int' <LValueToRValue>
53 //CHECK-NEXT: DeclRefExpr
54 //CHECK-SAME: 'i' 'int'
55 //CHECK-NEXT: IntegerLiteral
56 //CHECK-NEXT: ImplicitCastExpr
57 //CHECK-SAME: 'float' <LValueToRValue>
58 //CHECK-NEXT: DeclRefExpr
59 //CHECK-SAME: 'f' 'float'
61 __builtin_isfinite(f);
62 //CHECK: CallExpr
63 //CHECK-NEXT: ImplicitCastExpr
64 //CHECK-SAME: <BuiltinFnToFnPtr>
65 //CHECK-NEXT: DeclRefExpr
66 //CHECK-SAME: '__builtin_isfinite'
67 //CHECK-NEXT: ImplicitCastExpr
68 //CHECK-SAME: 'float' <LValueToRValue>
69 //CHECK-NEXT: DeclRefExpr
70 //CHECK-SAME: 'f' 'float'
72 __builtin_isfinite(d);
73 //CHECK: CallExpr
74 //CHECK-NEXT: ImplicitCastExpr
75 //CHECK-SAME: <BuiltinFnToFnPtr>
76 //CHECK-NEXT: DeclRefExpr
77 //CHECK-SAME: '__builtin_isfinite'
78 //CHECK-NEXT: ImplicitCastExpr
79 //CHECK-SAME: 'double' <LValueToRValue>
80 //CHECK-NEXT: DeclRefExpr
81 //CHECK-SAME: 'd' 'double'
82 #else
83 struct S s;
84 // expected-error@+1{{passing 'struct S' to parameter of incompatible type 'int'}}
85 __builtin_fpclassify(d, s, i, i, 3, d);
86 // expected-error@+1{{floating point classification requires argument of floating point type (passed in 'int')}}
87 __builtin_fpclassify(d, 1, i, i, 3, i);
88 // expected-error@+1{{floating point classification requires argument of floating point type (passed in 'int')}}
89 __builtin_isfinite(i);
90 #endif