Commit de83a4c1 by Iain Buclaw Committed by Iain Buclaw

d/dmd: Merge upstream dmd 375ed10aa

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
parent edf09592
2019-08-20 Iain Buclaw <ibuclaw@gdcproject.org> 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 PR d/90446
* d-lang.cc (d_type_for_mode): Check for all internal __intN types. * d-lang.cc (d_type_for_mode): Check for all internal __intN types.
(d_type_for_size): Likewise. (d_type_for_size): Likewise.
......
...@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree.h" #include "tree.h"
#include "memmodel.h" #include "memmodel.h"
#include "fold-const.h" #include "fold-const.h"
#include "diagnostic.h"
#include "stor-layout.h" #include "stor-layout.h"
#include "tm.h" #include "tm.h"
#include "tm_p.h" #include "tm_p.h"
...@@ -145,17 +146,24 @@ Target::_init (void) ...@@ -145,17 +146,24 @@ Target::_init (void)
Target::maxStaticDataSize = tree_to_shwi (TYPE_MAX_VALUE (integer_type_node)); Target::maxStaticDataSize = tree_to_shwi (TYPE_MAX_VALUE (integer_type_node));
/* Define what type to use for size_t, ptrdiff_t. */ /* Define what type to use for size_t, ptrdiff_t. */
if (POINTER_SIZE == 64) if (Target::ptrsize == 8)
{ {
global.params.isLP64 = true; global.params.isLP64 = true;
Tsize_t = Tuns64; Tsize_t = Tuns64;
Tptrdiff_t = Tint64; Tptrdiff_t = Tint64;
} }
else else if (Target::ptrsize == 4)
{ {
Tsize_t = Tuns32; Tsize_t = Tuns32;
Tptrdiff_t = Tint32; 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::tsize_t = Type::basic[Tsize_t];
Type::tptrdiff_t = Type::basic[Tptrdiff_t]; Type::tptrdiff_t = Type::basic[Tptrdiff_t];
......
792f0fdf249b21531dc91690024827f4f9ecbb97 375ed10aa7eb28755f92775ca5c5399550cd100b
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository. merge done from the dlang/dmd repository.
...@@ -2920,10 +2920,12 @@ void IntegerExp::normalize() ...@@ -2920,10 +2920,12 @@ void IntegerExp::normalize()
case Tint64: value = (d_int64) value; break; case Tint64: value = (d_int64) value; break;
case Tuns64: value = (d_uns64) value; break; case Tuns64: value = (d_uns64) value; break;
case Tpointer: case Tpointer:
if (Target::ptrsize == 4) if (Target::ptrsize == 8)
value = (d_uns32) value;
else if (Target::ptrsize == 8)
value = (d_uns64) value; value = (d_uns64) value;
else if (Target::ptrsize == 4)
value = (d_uns32) value;
else if (Target::ptrsize == 2)
value = (d_uns16) value;
else else
assert(0); assert(0);
break; break;
......
...@@ -2152,10 +2152,12 @@ public: ...@@ -2152,10 +2152,12 @@ public:
if ((sinteger_t)uval >= 0) if ((sinteger_t)uval >= 0)
{ {
dinteger_t sizemax; dinteger_t sizemax;
if (Target::ptrsize == 4) if (Target::ptrsize == 8)
sizemax = 0xFFFFFFFFUL;
else if (Target::ptrsize == 8)
sizemax = 0xFFFFFFFFFFFFFFFFULL; sizemax = 0xFFFFFFFFFFFFFFFFULL;
else if (Target::ptrsize == 4)
sizemax = 0xFFFFFFFFUL;
else if (Target::ptrsize == 2)
sizemax = 0xFFFFUL;
else else
assert(0); assert(0);
if (uval <= sizemax && uval <= 0x7FFFFFFFFFFFFFFFULL) if (uval <= sizemax && uval <= 0x7FFFFFFFFFFFFFFFULL)
...@@ -2296,12 +2298,10 @@ public: ...@@ -2296,12 +2298,10 @@ public:
buf->writestring("cast("); buf->writestring("cast(");
buf->writestring(t->toChars()); buf->writestring(t->toChars());
buf->writeByte(')'); buf->writeByte(')');
if (Target::ptrsize == 4) if (Target::ptrsize == 8)
goto L3;
else if (Target::ptrsize == 8)
goto L4; goto L4;
else else
assert(0); goto L3;
default: default:
/* This can happen if errors, such as /* This can happen if errors, such as
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment