d/dmd: Merge upstream dmd 375ed10aa
authorIain Buclaw <ibuclaw@gdcproject.org>
Wed, 21 Aug 2019 07:53:35 +0000 (07:53 +0000)
committerIain Buclaw <ibuclaw@gcc.gnu.org>
Wed, 21 Aug 2019 07:53:35 +0000 (07:53 +0000)
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

gcc/d/ChangeLog
gcc/d/d-target.cc
gcc/d/dmd/MERGE
gcc/d/dmd/expression.c
gcc/d/dmd/hdrgen.c

index 41ea48e8b158121a8565fcff05ebf662cee86fbc..011b0d44fa037dc0bf938b07d0bf46d67fc2729a 100644 (file)
@@ -1,3 +1,10 @@
+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
index 8d85534f05444c8612d07d055ee5ffb1b8d3abe8..dfaf9bf3792c80322f4a2f048a019af8970c5e65 100644 (file)
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree.h"
 #include "memmodel.h"
 #include "fold-const.h"
+#include "diagnostic.h"
 #include "stor-layout.h"
 #include "tm.h"
 #include "tm_p.h"
@@ -145,17 +146,24 @@ Target::_init (void)
   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];
index d208aea3717cee2dbab73402e7e0e126ca9a72f0..cb7b6bfac7ff7ff1ccb57a05cb6cf4f5ae3b6e35 100644 (file)
@@ -1,4 +1,4 @@
-792f0fdf249b21531dc91690024827f4f9ecbb97
+375ed10aa7eb28755f92775ca5c5399550cd100b
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index c674392095e21c6b756b3adbdc42c66001819e2b..5f1bfa8f5a9863f34e1ee5775fd0123da08d3a3e 100644 (file)
@@ -2920,10 +2920,12 @@ void IntegerExp::normalize()
         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;
index 4eaa1ae10501494ff6ca35a5ee17c01cab2ff379..395aa3212b5e47f4a902ec9a46334837fa56f921 100644 (file)
@@ -2152,10 +2152,12 @@ public:
             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)
@@ -2296,12 +2298,10 @@ public:
                     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