146 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -target-feature -x872// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -DNOERROR3 4#ifdef NOERROR5// expected-no-diagnostics6#endif7 8typedef long double long_double;9 10// Declaration is fine, unless it is called or defined.11double decl(long_double x, long_double y);12 13template <typename T>14T decl_ld_del(T);15 16// No code is generated for deleted functions17long_double decl_ld_del(long_double) = delete;18double decl_ld_del(double) = delete;19float decl_ld_del(float) = delete;20 21#ifndef NOERROR22// expected-error@+4{{'def' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}23// expected-note@+3{{'def' defined here}}24// expected-note@+2{{'x' defined here}}25#endif26int def(long_double x) {27#ifndef NOERROR28// expected-error@+2{{'x' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}29#endif30 return (int)x;31}32 33#ifndef NOERROR34// expected-note@+3{{'ld_args' defined here}}35// expected-note@+2{{'ld_args' defined here}}36#endif37int ld_args(long_double x, long_double y);38 39int call1(float x, float y) {40#ifndef NOERROR41 // expected-error@+2 2{{'ld_args' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}42#endif43 return ld_args(x, y);44}45 46#ifndef NOERROR47// expected-note@+2{{'ld_ret' defined here}}48#endif49long_double ld_ret(double x, double y);50 51int call2(float x, float y) {52#ifndef NOERROR53 // expected-error@+2{{'ld_ret' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}54#endif55 return (int)ld_ret(x, y);56}57 58int binop(double x, double y) {59#ifndef NOERROR60 // expected-error@+2 2{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}61#endif62 double z = (long_double)x * (long_double)y;63 return (int)z;64}65 66void assign1(long_double *ret, double x) {67#ifndef NOERROR68 // expected-error@+2{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}69#endif70 *ret = x;71}72 73struct st_long_double1 {74#ifndef NOERROR75 // expected-note@+2{{'ld' defined here}}76#endif77 long_double ld;78};79 80struct st_long_double2 {81#ifndef NOERROR82 // expected-note@+2{{'ld' defined here}}83#endif84 long_double ld;85};86 87struct st_long_double3 {88#ifndef NOERROR89 // expected-note@+2{{'ld' defined here}}90#endif91 long_double ld;92};93 94void assign2() {95 struct st_long_double1 st;96#ifndef NOERROR97 // expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}98 // expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}99#endif100 st.ld = 0.42;101}102 103void assign3() {104 struct st_long_double2 st;105#ifndef NOERROR106 // expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}107 // expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}108#endif109 st.ld = 42;110}111 112void assign4(double d) {113 struct st_long_double3 st;114#ifndef NOERROR115 // expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}116 // expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}117#endif118 st.ld = d;119}120 121void assign5() {122 // unused variable declaration is fine123 long_double ld = 0.42;124}125 126// Double and Float return type on x86_64 do not use x87 registers127double d_ret1(float x) {128 return 0.0;129}130 131double d_ret2(float x);132 133int d_ret3(float x) {134 return (int)d_ret2(x);135}136 137float f_ret1(float x) {138 return 0.0f;139}140 141float f_ret2(float x);142 143int f_ret3(float x) {144 return (int)f_ret2(x);145}146