win32: long double as distinct C-type

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.
This commit is contained in:
grischka 2020-02-23 00:11:03 +01:00
parent d019586378
commit 6696da2f61
3 changed files with 16 additions and 2 deletions

View File

@ -3244,7 +3244,8 @@ static void type_to_str(char *buf, int buf_size,
goto add_tstr;
case VT_DOUBLE:
tstr = "double";
goto add_tstr;
if (!(t & VT_LONG))
goto add_tstr;
case VT_LDOUBLE:
tstr = "long double";
add_tstr:
@ -4589,7 +4590,7 @@ the_end:
t |= LONG_SIZE == 8 ? VT_LLONG : VT_INT;
#ifdef TCC_TARGET_PE
if (bt == VT_LDOUBLE)
t = (t & ~(VT_BTYPE|VT_LONG)) | VT_DOUBLE;
t = (t & ~(VT_BTYPE|VT_LONG)) | (VT_DOUBLE|VT_LONG);
#endif
type->t = t;
return type_found;

View File

@ -308,5 +308,15 @@ void f2() {
struct yyy y, *yy;
struct zzz { int z; } z, *zz;
/******************************************************************/
#elif defined test_long_double_type_for_win32
int main()
{
double *a = 0;
long double *b = a;
int n = _Generic(*a, double:0, long double:1);
}
/******************************************************************/
#endif

View File

@ -147,3 +147,6 @@ bar : 3 ; 3
60_errors_and_warnings.c:286: error: incompatible types for redefinition of 'xxx'
[test_var_4]
[test_long_double_type_for_win32]
60_errors_and_warnings.c:317: warning: assignment from incompatible pointer type