| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple i686-linux-gnu -target-feature -x87 |
| 2 |
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple i686-linux-gnu -DNOERROR |
| 3 |
|
| 4 |
#ifdef NOERROR |
| 5 |
// expected-no-diagnostics |
| 6 |
#endif |
| 7 |
|
| 8 |
typedef long double long_double; |
| 9 |
|
| 10 |
// Declaration is fine, unless it is called or defined. |
| 11 |
double decl(long_double x, long_double y); |
| 12 |
|
| 13 |
template <typename T> |
| 14 |
T decl_ld_del(T); |
| 15 |
|
| 16 |
// No code is generated for deleted functions |
| 17 |
long_double decl_ld_del(long_double) = delete; |
| 18 |
double decl_ld_del(double) = delete; |
| 19 |
float decl_ld_del(float) = delete; |
| 20 |
|
| 21 |
#ifndef NOERROR |
| 22 |
// expected-error@+4{{'def' requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 23 |
// expected-note@+3{{'def' defined here}} |
| 24 |
// expected-note@+2{{'x' defined here}} |
| 25 |
#endif |
| 26 |
int def(long_double x) { |
| 27 |
#ifndef NOERROR |
| 28 |
// expected-error@+2{{'x' requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 29 |
#endif |
| 30 |
return (int)x; |
| 31 |
} |
| 32 |
|
| 33 |
#ifndef NOERROR |
| 34 |
// expected-note@+3{{'ld_args' defined here}} |
| 35 |
// expected-note@+2{{'ld_args' defined here}} |
| 36 |
#endif |
| 37 |
int ld_args(long_double x, long_double y); |
| 38 |
|
| 39 |
int call1(float x, float y) { |
| 40 |
#ifndef NOERROR |
| 41 |
// expected-error@+2 2{{'ld_args' requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 42 |
#endif |
| 43 |
return ld_args(x, y); |
| 44 |
} |
| 45 |
|
| 46 |
#ifndef NOERROR |
| 47 |
// expected-note@+2{{'ld_ret' defined here}} |
| 48 |
#endif |
| 49 |
long_double ld_ret(double x, double y); |
| 50 |
|
| 51 |
int call2(float x, float y) { |
| 52 |
#ifndef NOERROR |
| 53 |
// expected-error@+2{{'ld_ret' requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 54 |
#endif |
| 55 |
return (int)ld_ret(x, y); |
| 56 |
} |
| 57 |
|
| 58 |
int binop(double x, double y) { |
| 59 |
#ifndef NOERROR |
| 60 |
// expected-error@+2 2{{expression requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 61 |
#endif |
| 62 |
double z = (long_double)x * (long_double)y; |
| 63 |
return (int)z; |
| 64 |
} |
| 65 |
|
| 66 |
void assign1(long_double *ret, double x) { |
| 67 |
#ifndef NOERROR |
| 68 |
// expected-error@+2{{expression requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 69 |
#endif |
| 70 |
*ret = x; |
| 71 |
} |
| 72 |
|
| 73 |
struct st_long_double1 { |
| 74 |
#ifndef NOERROR |
| 75 |
// expected-note@+2{{'ld' defined here}} |
| 76 |
#endif |
| 77 |
long_double ld; |
| 78 |
}; |
| 79 |
|
| 80 |
struct st_long_double2 { |
| 81 |
#ifndef NOERROR |
| 82 |
// expected-note@+2{{'ld' defined here}} |
| 83 |
#endif |
| 84 |
long_double ld; |
| 85 |
}; |
| 86 |
|
| 87 |
struct st_long_double3 { |
| 88 |
#ifndef NOERROR |
| 89 |
// expected-note@+2{{'ld' defined here}} |
| 90 |
#endif |
| 91 |
long_double ld; |
| 92 |
}; |
| 93 |
|
| 94 |
void assign2() { |
| 95 |
struct st_long_double1 st; |
| 96 |
#ifndef NOERROR |
| 97 |
// expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 98 |
// expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 99 |
#endif |
| 100 |
st.ld = 0.42; |
| 101 |
} |
| 102 |
|
| 103 |
void assign3() { |
| 104 |
struct st_long_double2 st; |
| 105 |
#ifndef NOERROR |
| 106 |
// expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 107 |
// expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 108 |
#endif |
| 109 |
st.ld = 42; |
| 110 |
} |
| 111 |
|
| 112 |
void assign4(double d) { |
| 113 |
struct st_long_double3 st; |
| 114 |
#ifndef NOERROR |
| 115 |
// expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 116 |
// expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'i686-unknown-linux-gnu' does not support it}} |
| 117 |
#endif |
| 118 |
st.ld = d; |
| 119 |
} |
| 120 |
|
| 121 |
void assign5() { |
| 122 |
// unused variable declaration is fine |
| 123 |
long_double ld = 0.42; |
| 124 |
} |
| 125 |
|
| 126 |
double d_ret1(float x) { |
| 127 |
return 0.0; |
| 128 |
} |
| 129 |
|
| 130 |
double d_ret2(float x); |
| 131 |
|
| 132 |
int d_ret3(float x) { |
| 133 |
return (int)d_ret2(x); |
| 134 |
} |
| 135 |
|
| 136 |
float f_ret1(float x) { |
| 137 |
return 0.0f; |
| 138 |
} |
| 139 |
|
| 140 |
float f_ret2(float x); |
| 141 |
|
| 142 |
int f_ret3(float x) { |
| 143 |
return (int)f_ret2(x); |
| 144 |
} |