[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / arm-bf16-forbidden-ops.c
blob0311e7bfb7b37130929a7405b10ac05e7967d887
1 // RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64 -target-feature +bf16 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64 -target-feature -bf16 %s
4 __bf16 test_cast_from_float(float in) {
5 return (__bf16)in; // expected-error {{cannot type-cast to __bf16}}
8 __bf16 test_cast_from_float_literal(void) {
9 return (__bf16)1.0f; // expected-error {{cannot type-cast to __bf16}}
12 __bf16 test_cast_from_int(int in) {
13 return (__bf16)in; // expected-error {{cannot type-cast to __bf16}}
16 __bf16 test_cast_from_int_literal(void) {
17 return (__bf16)1; // expected-error {{cannot type-cast to __bf16}}
20 __bf16 test_cast_bfloat(__bf16 in) {
21 return (__bf16)in; // this one should work
24 float test_cast_to_float(__bf16 in) {
25 return (float)in; // expected-error {{cannot type-cast from __bf16}}
28 int test_cast_to_int(__bf16 in) {
29 return (int)in; // expected-error {{cannot type-cast from __bf16}}
32 __bf16 test_implicit_from_float(float in) {
33 return in; // expected-error {{returning 'float' from a function with incompatible result type '__bf16'}}
36 __bf16 test_implicit_from_float_literal(void) {
37 return 1.0f; // expected-error {{returning 'float' from a function with incompatible result type '__bf16'}}
40 __bf16 test_implicit_from_int(int in) {
41 return in; // expected-error {{returning 'int' from a function with incompatible result type '__bf16'}}
44 __bf16 test_implicit_from_int_literal(void) {
45 return 1; // expected-error {{returning 'int' from a function with incompatible result type '__bf16'}}
48 __bf16 test_implicit_bfloat(__bf16 in) {
49 return in; // this one should work
52 float test_implicit_to_float(__bf16 in) {
53 return in; // expected-error {{returning '__bf16' from a function with incompatible result type 'float'}}
56 int test_implicit_to_int(__bf16 in) {
57 return in; // expected-error {{returning '__bf16' from a function with incompatible result type 'int'}}
60 __bf16 test_cond(__bf16 a, __bf16 b, _Bool which) {
61 // Conditional operator _should_ be supported, without nonsense
62 // complaints like 'types __bf16 and __bf16 are not compatible'
63 return which ? a : b;
66 __bf16 test_cond_float(__bf16 a, __bf16 b, _Bool which) {
67 return which ? a : 1.0f; // expected-error {{incompatible operand types ('__bf16' and 'float')}}
70 __bf16 test_cond_int(__bf16 a, __bf16 b, _Bool which) {
71 return which ? a : 1; // expected-error {{incompatible operand types ('__bf16' and 'int')}}