1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 506170 - Calculate sizeof(double) correctly

Change-Id: Ie0b4767a81ed529e827d1b9decd4d065225e8e5b
This commit is contained in:
Nathan Ridge 2016-10-26 01:57:25 -04:00
parent e7e66605f2
commit f229ec9e44
3 changed files with 10 additions and 2 deletions

View file

@ -12131,4 +12131,10 @@ public class AST2CPPTests extends AST2TestBase {
public void testDecltypeAutoReturnType_482225() throws Exception {
parseAndCheckBindings();
}
// constexpr int waldo = (sizeof(double) % 16);
public void testSizeofDouble_506170() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 8);
}
}

View file

@ -151,6 +151,7 @@ public class AST2TestBase extends BaseTestCase {
map.put("__SIZEOF_SHORT__", "2");
map.put("__SIZEOF_INT__", "4");
map.put("__SIZEOF_LONG__", "8");
map.put("__SIZEOF_DOUBLE__", "8");
map.put("__SIZEOF_POINTER__", "8");
return map;
}
@ -160,6 +161,7 @@ public class AST2TestBase extends BaseTestCase {
map.put("__SIZEOF_SHORT__", "2");
map.put("__SIZEOF_INT__", "4");
map.put("__SIZEOF_LONG__", "8");
map.put("__SIZEOF_DOUBLE__", "8");
map.put("__SIZEOF_POINTER__", "8");
return map;
}

View file

@ -238,8 +238,8 @@ public class SizeofCalculator {
return type.isComplex() ? sizeof_complex_float : sizeof_float;
case eDouble:
return type.isComplex() ?
(type.isLong() ? sizeof_long_double : sizeof_double) :
(type.isLong() ? sizeof_complex_long_double : sizeof_complex_double);
(type.isLong() ? sizeof_complex_long_double : sizeof_complex_double) :
(type.isLong() ? sizeof_long_double : sizeof_double);
case eFloat128:
return type.isComplex() ? sizeof_complex_float128 : sizeof_float128;
case eDecimal32: