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 | 3244 | goto add_tstr; |
| 3245 | 3245 | case VT_DOUBLE: |
| 3246 | 3246 | tstr = "double"; |
| 3247 | − goto add_tstr; | |
| 3247 | + if (!(t & VT_LONG)) | |
| 3248 | + goto add_tstr; | |
| 3248 | 3249 | case VT_LDOUBLE: |
| 3249 | 3250 | tstr = "long double"; |
| 3250 | 3251 | add_tstr: |
| @@ -4589,7 +4590,7 @@ the_end: · 1338 unmodified lines | ||
| 4589 | 4590 | t |= LONG_SIZE == 8 ? VT_LLONG : VT_INT; |
| 4590 | 4591 | #ifdef TCC_TARGET_PE |
| 4591 | 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 | 4594 | #endif |
| 4594 | 4595 | type->t = t; |
| 4595 | 4596 | return type_found; |
| @@ -308,5 +308,15 @@ void f2() { · 307 unmodified lines | ||
| 308 | 308 | struct yyy y, *yy; |
| 309 | 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 | 322 | #endif |
| @@ -147,3 +147,6 @@ bar : 3 ; 3 · 146 unmodified lines | ||
| 147 | 147 | 60_errors_and_warnings.c:286: error: incompatible types for redefinition of 'xxx' |
| 148 | 148 | |
| 149 | 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 | |