History

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.

grischka committed 6 years ago

Commit 6696da21 parent d0195863 files · +16 −2Browse files

Unified · Split

3 files
  1. tccgen.c +3 −2
  2. tests/tests2/60_errors_and_warnings.c +10 −0
  3. tests/tests2/60_errors_and_warnings.expect +3 −0
tccgen.c+3−2
@@ -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_PE4591#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#endif4594#endif
4594 type->t = t;4595 type->t = t;
4595 return type_found;4596 return type_found;
tests/tests2/60_errors_and_warnings.c+10−0
@@ -308,5 +308,15 @@ void f2() { · 307 unmodified lines
308struct yyy y, *yy;308struct yyy y, *yy;
309struct zzz { int z; } z, *zz;309struct zzz { int z; } z, *zz;
310 310
311/******************************************************************/
312#elif defined test_long_double_type_for_win32
313
314int 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#endif322#endif
tests/tests2/60_errors_and_warnings.expect+3−0
@@ -147,3 +147,6 @@ bar : 3 ; 3 · 146 unmodified lines
14760_errors_and_warnings.c:286: error: incompatible types for redefinition of 'xxx'14760_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]
15260_errors_and_warnings.c:317: warning: assignment from incompatible pointer type

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t