On windows. there is no long double really IOW it is the same as double. However setting the VT_LONG flag in combination with VT_DOUBLE allows to keep track of the original type for the purpose of '_Generic() or more accurate type warnings.
Unified · Split
| @@ -3244,7 +3244,8 @@ static void type_to_str(char *buf, int buf_size, · 3243 unmodified lines | |||
| 3244 | goto add_tstr; | 3244 | goto add_tstr; |
| 3245 | case VT_DOUBLE: | 3245 | case VT_DOUBLE: |
| 3246 | tstr = "double"; | 3246 | tstr = "double"; |
| 3247 | goto add_tstr; | 3247 | if (!(t & VT_LONG)) |
| 3248 | goto add_tstr; | ||
| 3248 | case VT_LDOUBLE: | 3249 | case VT_LDOUBLE: |
| 3249 | tstr = "long double"; | 3250 | tstr = "long double"; |
| 3250 | add_tstr: | 3251 | add_tstr: |
| @@ -4589,7 +4590,7 @@ the_end: · 1338 unmodified lines | |||
| 4589 | t |= LONG_SIZE == 8 ? VT_LLONG : VT_INT; | 4590 | t |= LONG_SIZE == 8 ? VT_LLONG : VT_INT; |
| 4590 | #ifdef TCC_TARGET_PE | 4591 | #ifdef TCC_TARGET_PE |
| 4591 | if (bt == VT_LDOUBLE) | 4592 | if (bt == VT_LDOUBLE) |
| 4592 | t = (t & ~(VT_BTYPE|VT_LONG)) | VT_DOUBLE; | 4593 | t = (t & ~(VT_BTYPE|VT_LONG)) | (VT_DOUBLE|VT_LONG); |
| 4593 | #endif | 4594 | #endif |
| 4594 | type->t = t; | 4595 | type->t = t; |
| 4595 | return type_found; | 4596 | return type_found; |
| @@ -308,5 +308,15 @@ void f2() { · 307 unmodified lines | |||
| 308 | struct yyy y, *yy; | 308 | struct yyy y, *yy; |
| 309 | struct zzz { int z; } z, *zz; | 309 | struct zzz { int z; } z, *zz; |
| 310 | 310 | ||
| 311 | /******************************************************************/ | ||
| 312 | #elif defined test_long_double_type_for_win32 | ||
| 313 | |||
| 314 | int main() | ||
| 315 | { | ||
| 316 | double *a = 0; | ||
| 317 | long double *b = a; | ||
| 318 | int n = _Generic(*a, double:0, long double:1); | ||
| 319 | } | ||
| 320 | |||
| 311 | /******************************************************************/ | 321 | /******************************************************************/ |
| 312 | #endif | 322 | #endif |
| @@ -147,3 +147,6 @@ bar : 3 ; 3 · 146 unmodified lines | |||
| 147 | 60_errors_and_warnings.c:286: error: incompatible types for redefinition of 'xxx' | 147 | 60_errors_and_warnings.c:286: error: incompatible types for redefinition of 'xxx' |
| 148 | 148 | ||
| 149 | [test_var_4] | 149 | [test_var_4] |
| 150 | |||
| 151 | [test_long_double_type_for_win32] | ||
| 152 | 60_errors_and_warnings.c:317: warning: assignment from incompatible pointer type | ||