Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only %s |
Daniel Dunbar | 5db4b3f | 2008-10-16 03:51:50 +0000 | [diff] [blame] | 2 | |
| 3 | // Math stuff |
| 4 | |
| 5 | double g0 = __builtin_huge_val(); |
| 6 | float g1 = __builtin_huge_valf(); |
| 7 | long double g2 = __builtin_huge_vall(); |
| 8 | |
| 9 | double g3 = __builtin_inf(); |
| 10 | float g4 = __builtin_inff(); |
| 11 | long double g5 = __builtin_infl(); |
| 12 | |
| 13 | double g6 = __builtin_nan(""); |
| 14 | float g7 = __builtin_nanf(""); |
| 15 | long double g8 = __builtin_nanl(""); |
| 16 | |
| 17 | // GCC constant folds these too (via native strtol): |
| 18 | //double g6_1 = __builtin_nan("1"); |
| 19 | //float g7_1 = __builtin_nanf("1"); |
| 20 | //long double g8_1 = __builtin_nanl("1"); |
| 21 | |
| 22 | // APFloat doesn't have signalling NaN functions. |
| 23 | //double g9 = __builtin_nans(""); |
| 24 | //float g10 = __builtin_nansf(""); |
| 25 | //long double g11 = __builtin_nansl(""); |
| 26 | |
| 27 | //int g12 = __builtin_abs(-12); |
| 28 | |
| 29 | double g13 = __builtin_fabs(-12.); |
| 30 | double g13_0 = __builtin_fabs(-0.); |
| 31 | double g13_1 = __builtin_fabs(-__builtin_inf()); |
| 32 | float g14 = __builtin_fabsf(-12.f); |
| 33 | // GCC doesn't eat this one. |
| 34 | //long double g15 = __builtin_fabsfl(-12.0L); |
| 35 | |
| 36 | float g16 = __builtin_copysign(1.0, -1.0); |
| 37 | double g17 = __builtin_copysignf(1.0f, -1.0f); |
| 38 | long double g18 = __builtin_copysignl(1.0L, -1.0L); |
| 39 | |
| 40 | //double g19 = __builtin_powi(2.0, 4); |
| 41 | //float g20 = __builtin_powif(2.0f, 4); |
| 42 | //long double g21 = __builtin_powil(2.0L, 4); |
| 43 | |
| 44 | // GCC misc stuff |
| 45 | |
| 46 | extern int f(); |
| 47 | |
| 48 | int h0 = __builtin_types_compatible_p(int, float); |
| 49 | //int h1 = __builtin_choose_expr(1, 10, f()); |
| 50 | //int h2 = __builtin_expect(0, 0); |
Douglas Gregor | df7c3b9 | 2009-10-31 16:04:14 +0000 | [diff] [blame] | 51 | extern long int bi0; |
| 52 | extern __typeof__(__builtin_expect(0, 0)) bi0; |
Douglas Gregor | 5726d40 | 2010-09-10 06:27:15 +0000 | [diff] [blame] | 53 | |
| 54 | // Strings |
| 55 | int array1[__builtin_strlen("ab\0cd")]; |
| 56 | int array2[(sizeof(array1)/sizeof(int)) == 2? 1 : -1]; |