xref: /llvm-project/clang/test/CodeGen/PowerPC/ibm128-cast.c (revision 7c1d9b15eee3a34678addab2bab66f3020ac0753)
1 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -verify \
2 // RUN:   -target-feature +float128 -mabi=ieeelongdouble -fsyntax-only -Wno-unused %s
3 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -verify \
4 // RUN:   -target-feature +float128 -fsyntax-only -Wno-unused %s
5 
cast1(__ibm128 x)6 __float128 cast1(__ibm128 x) { return x; } // expected-error {{returning '__ibm128' from a function with incompatible result type '__float128'}}
7 
cast2(__float128 x)8 __ibm128 cast2(__float128 x) { return x; } // expected-error {{returning '__float128' from a function with incompatible result type '__ibm128'}}
9 
10 __ibm128 gf;
11 
narrow(double * d,float * f)12 void narrow(double *d, float *f) {
13   __ibm128 v = gf;
14   gf = *d;      // expected-no-error {{assigning to '__ibm128' from incompatible type 'double'}}
15   *f = v;       // expected-no-error {{assigning to 'float' from incompatible type '__ibm128'}}
16   *d = gf + *f; // expected-no-error {{invalid operands to binary expression ('__ibm128' and 'float')}}
17 }
18 
19 #ifdef __LONG_DOUBLE_IEEE128__
cast3(__ibm128 x)20 long double cast3(__ibm128 x) { return x; } // expected-error {{returning '__ibm128' from a function with incompatible result type 'long double'}}
21 
cast4(long double x)22 __ibm128 cast4(long double x) { return x; } // expected-error {{returning 'long double' from a function with incompatible result type '__ibm128'}}
23 
imp_cast(__ibm128 w,__float128 q,long double l,_Bool b)24 void imp_cast(__ibm128 w, __float128 q, long double l, _Bool b) {
25   w + q;      // expected-error {{invalid operands to binary expression ('__ibm128' and '__float128')}}
26   l + w;      // expected-error {{invalid operands to binary expression ('long double' and '__ibm128')}}
27   q - w;      // expected-error {{invalid operands to binary expression ('__float128' and '__ibm128')}}
28   w - l;      // expected-error {{invalid operands to binary expression ('__ibm128' and 'long double')}}
29   w *l;       // expected-error {{invalid operands to binary expression ('__ibm128' and 'long double')}}
30   q *w;       // expected-error {{invalid operands to binary expression ('__float128' and '__ibm128')}}
31   q / w;      // expected-error {{invalid operands to binary expression ('__float128' and '__ibm128')}}
32   w / l;      // expected-error {{invalid operands to binary expression ('__ibm128' and 'long double')}}
33   w = q;      // expected-error {{assigning to '__ibm128' from incompatible type '__float128'}}
34   q = w;      // expected-error {{assigning to '__float128' from incompatible type '__ibm128'}}
35   l = w;      // expected-error {{assigning to 'long double' from incompatible type '__ibm128'}}
36   w = l;      // expected-error {{assigning to '__ibm128' from incompatible type 'long double'}}
37   b ? q : w;  // expected-error {{incompatible operand types ('__float128' and '__ibm128')}}
38   !b ? w : l; // expected-error {{incompatible operand types ('__ibm128' and 'long double')}}
39 }
40 #elif __LONG_DOUBLE_IBM128__
cast3(__ibm128 x)41 long double cast3(__ibm128 x) { return x; } // expected-no-error {{returning '__ibm128' from a function with incompatible result type 'long double'}}
42 
cast4(long double x)43 __ibm128 cast4(long double x) { return x; } // expected-no-error {{returning 'long double' from a function with incompatible result type '__ibm128'}}
44 
imp_cast(__ibm128 w,__float128 q,long double l,_Bool b)45 void imp_cast(__ibm128 w, __float128 q, long double l, _Bool b) {
46   w + q;      // expected-error {{invalid operands to binary expression ('__ibm128' and '__float128')}}
47   l + w;      // expected-no-error {{invalid operands to binary expression ('long double' and '__ibm128')}}
48   q - w;      // expected-error {{invalid operands to binary expression ('__float128' and '__ibm128')}}
49   w - l;      // expected-no-error {{invalid operands to binary expression ('__ibm128' and 'long double')}}
50   w *l;       // expected-no-error {{invalid operands to binary expression ('__ibm128' and 'long double')}}
51   q *w;       // expected-error {{invalid operands to binary expression ('__float128' and '__ibm128')}}
52   q / w;      // expected-error {{invalid operands to binary expression ('__float128' and '__ibm128')}}
53   w / l;      // expected-no-error {{invalid operands to binary expression ('__ibm128' and 'long double')}}
54   w = q;      // expected-error {{assigning to '__ibm128' from incompatible type '__float128'}}
55   q = w;      // expected-error {{assigning to '__float128' from incompatible type '__ibm128'}}
56   l = w;      // expected-no-error {{assigning to 'long double' from incompatible type '__ibm128'}}
57   w = l;      // expected-no-error {{assigning to '__ibm128' from incompatible type 'long double'}}
58   b ? q : w;  // expected-error {{incompatible operand types ('__float128' and '__ibm128')}}
59   !b ? w : l; // expected-no-error {{incompatible operand types ('__ibm128' and 'long double')}}
60 }
61 #endif
62