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
32443244 goto add_tstr;
32453245 case VT_DOUBLE:
32463246 tstr = "double";
3247− goto add_tstr;
3247+ if (!(t & VT_LONG))
3248+ goto add_tstr;
32483249 case VT_LDOUBLE:
32493250 tstr = "long double";
32503251 add_tstr:
@@ -4589,7 +4590,7 @@ the_end: · 1338 unmodified lines
45894590 t |= LONG_SIZE == 8 ? VT_LLONG : VT_INT;
45904591 #ifdef TCC_TARGET_PE
45914592 if (bt == VT_LDOUBLE)
4592− t = (t & ~(VT_BTYPE|VT_LONG)) | VT_DOUBLE;
4593+ t = (t & ~(VT_BTYPE|VT_LONG)) | (VT_DOUBLE|VT_LONG);
45934594 #endif
45944595 type->t = t;
45954596 return type_found;
tests/tests2/60_errors_and_warnings.c+10−0
@@ -308,5 +308,15 @@ void f2() { · 307 unmodified lines
308308 struct yyy y, *yy;
309309 struct zzz { int z; } z, *zz;
310310
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+
311321 /******************************************************************/
312322 #endif
tests/tests2/60_errors_and_warnings.expect+3−0
@@ -147,3 +147,6 @@ bar : 3 ; 3 · 146 unmodified lines
147147 60_errors_and_warnings.c:286: error: incompatible types for redefinition of 'xxx'
148148
149149 [test_var_4]
150+
151+[test_long_double_type_for_win32]
152+60_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