Don't crash when compiling for 16-bit platforms.
Reviewed-on: https://github.com/dlang/dmd/pull/10306
gcc/d/ChangeLog:
* d-target.cc: Include diagnostic.h.
(Target::_init): Set Tsize_t and Tptrdiff_t as D ushort and short if
the target pointer size is 2. Add sorry if the pointer size is not
either 2, 4, or 8.
From-SVN: r274768
+2019-08-20 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ * d-target.cc: Include diagnostic.h.
+ (Target::_init): Set Tsize_t and Tptrdiff_t as D ushort and short if
+ the target pointer size is 2. Add sorry if the pointer size is not
+ either 2, 4, or 8.
+
2019-08-20 Iain Buclaw <ibuclaw@gdcproject.org>
PR d/90446
#include "tree.h"
#include "memmodel.h"
#include "fold-const.h"
+#include "diagnostic.h"
#include "stor-layout.h"
#include "tm.h"
#include "tm_p.h"
Target::maxStaticDataSize = tree_to_shwi (TYPE_MAX_VALUE (integer_type_node));
/* Define what type to use for size_t, ptrdiff_t. */
- if (POINTER_SIZE == 64)
+ if (Target::ptrsize == 8)
{
global.params.isLP64 = true;
Tsize_t = Tuns64;
Tptrdiff_t = Tint64;
}
- else
+ else if (Target::ptrsize == 4)
{
Tsize_t = Tuns32;
Tptrdiff_t = Tint32;
}
+ else if (Target::ptrsize == 2)
+ {
+ Tsize_t = Tuns16;
+ Tptrdiff_t = Tint16;
+ }
+ else
+ sorry ("D does not support pointers on this target.");
Type::tsize_t = Type::basic[Tsize_t];
Type::tptrdiff_t = Type::basic[Tptrdiff_t];
-792f0fdf249b21531dc91690024827f4f9ecbb97
+375ed10aa7eb28755f92775ca5c5399550cd100b
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
case Tint64: value = (d_int64) value; break;
case Tuns64: value = (d_uns64) value; break;
case Tpointer:
- if (Target::ptrsize == 4)
- value = (d_uns32) value;
- else if (Target::ptrsize == 8)
+ if (Target::ptrsize == 8)
value = (d_uns64) value;
+ else if (Target::ptrsize == 4)
+ value = (d_uns32) value;
+ else if (Target::ptrsize == 2)
+ value = (d_uns16) value;
else
assert(0);
break;
if ((sinteger_t)uval >= 0)
{
dinteger_t sizemax;
- if (Target::ptrsize == 4)
- sizemax = 0xFFFFFFFFUL;
- else if (Target::ptrsize == 8)
+ if (Target::ptrsize == 8)
sizemax = 0xFFFFFFFFFFFFFFFFULL;
+ else if (Target::ptrsize == 4)
+ sizemax = 0xFFFFFFFFUL;
+ else if (Target::ptrsize == 2)
+ sizemax = 0xFFFFUL;
else
assert(0);
if (uval <= sizemax && uval <= 0x7FFFFFFFFFFFFFFFULL)
buf->writestring("cast(");
buf->writestring(t->toChars());
buf->writeByte(')');
- if (Target::ptrsize == 4)
- goto L3;
- else if (Target::ptrsize == 8)
+ if (Target::ptrsize == 8)
goto L4;
else
- assert(0);
+ goto L3;
default:
/* This can happen if errors, such as