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_static_cast_from_float(float in
) {
5 return static_cast<__bf16
>(in
); // expected-error {{static_cast from 'float' to '__bf16' is not allowed}}
8 __bf16
test_static_cast_from_float_literal(void) {
9 return static_cast<__bf16
>(1.0f
); // expected-error {{static_cast from 'float' to '__bf16' is not allowed}}
12 __bf16
test_static_cast_from_int(int in
) {
13 return static_cast<__bf16
>(in
); // expected-error {{static_cast from 'int' to '__bf16' is not allowed}}
16 __bf16
test_static_cast_from_int_literal(void) {
17 return static_cast<__bf16
>(1); // expected-error {{static_cast from 'int' to '__bf16' is not allowed}}
20 __bf16
test_static_cast_bfloat(__bf16 in
) {
21 return static_cast<__bf16
>(in
); // this one should work
24 float test_static_cast_to_float(__bf16 in
) {
25 return static_cast<float>(in
); // expected-error {{static_cast from '__bf16' to 'float' is not allowed}}
28 int test_static_cast_to_int(__bf16 in
) {
29 return static_cast<int>(in
); // expected-error {{static_cast from '__bf16' to 'int' is not allowed}}
32 __bf16
test_implicit_from_float(float in
) {
33 return in
; // expected-error {{cannot initialize return object of type '__bf16' with an lvalue of type 'float'}}
36 __bf16
test_implicit_from_float_literal() {
37 return 1.0f
; // expected-error {{cannot initialize return object of type '__bf16' with an rvalue of type 'float'}}
40 __bf16
test_implicit_from_int(int in
) {
41 return in
; // expected-error {{cannot initialize return object of type '__bf16' with an lvalue of type 'int'}}
44 __bf16
test_implicit_from_int_literal() {
45 return 1; // expected-error {{cannot initialize return object of type '__bf16' with an rvalue of type 'int'}}
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 {{cannot initialize return object of type 'float' with an lvalue of type '__bf16'}}
56 int test_implicit_to_int(__bf16 in
) {
57 return in
; // expected-error {{cannot initialize return object of type 'int' with an lvalue of type '__bf16'}}
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'
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')}}