re PR d/90650 (ICE in fold_convert_loc, at fold-const.c:2552)
authorIain Buclaw <ibuclaw@gdcproject.org>
Sun, 16 Jun 2019 07:48:53 +0000 (07:48 +0000)
committerIain Buclaw <ibuclaw@gcc.gnu.org>
Sun, 16 Jun 2019 07:48:53 +0000 (07:48 +0000)
PR d/90650
d/dmd: Merge upstream dmd ab03e2918

Fixes internal compiler error in fold_convert_loc.

Reviewed-on: https://github.com/dlang/dmd/pull/9996

gcc/testsuite/ChangeLog:

2019-06-16  Iain Buclaw  <ibuclaw@gdcproject.org>

PR d/90650
* gdc.dg/pr90650a.d: New test.
* gdc.dg/pr90650b.d: New test.

From-SVN: r272344

gcc/d/dmd/MERGE
gcc/d/dmd/expressionsem.c
gcc/d/dmd/mtype.c
gcc/d/dmd/statementsem.c
gcc/testsuite/ChangeLog
gcc/testsuite/gdc.dg/pr90650a.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr90650b.d [new file with mode: 0644]

index 4cb2bbac46db424247fc1310d32ec7c413a589e8..7258fadb1bba992f40a3bd8431b6114882c3a933 100644 (file)
@@ -1,4 +1,4 @@
-f30c5dc790c17914463879157447acc671518735
+ab03e2918508d62efcc5ee66c9a912a331b33aa0
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index 19b7ccb72367d225718e28352d74533a9ae9d562..ebdfae584c8351f1e146f41b97a3e36b02ba15c8 100644 (file)
@@ -2185,6 +2185,9 @@ public:
         }
         if (exp->e1->op == TOKslice || exp->e1->type->ty == Tarray || exp->e1->type->ty == Tsarray)
         {
+            if (checkNonAssignmentArrayOp(exp->e1))
+                return setError();
+
             if (exp->e1->op == TOKslice)
                 ((SliceExp *)exp->e1)->arrayop = true;
 
@@ -6232,6 +6235,9 @@ public:
         assert(exp->e1->type && exp->e2->type);
         if (exp->e1->op == TOKslice || exp->e1->type->ty == Tarray || exp->e1->type->ty == Tsarray)
         {
+            if (checkNonAssignmentArrayOp(exp->e1))
+                return setError();
+
             // T[] ^^= ...
             if (exp->e2->implicitConvTo(exp->e1->type->nextOf()))
             {
index 058738ec8252f2a6d41df4ab8ba53962591f7930..2562f364b499f7e0f82fb195475ea31e127b2db2 100644 (file)
@@ -4468,6 +4468,8 @@ Expression *TypeDArray::dotExp(Scope *sc, Expression *e, Identifier *ident, int
         }
         if (e->op == TOKnull)
             return new IntegerExp(e->loc, 0, Type::tsize_t);
+        if (checkNonAssignmentArrayOp(e))
+            return new ErrorExp();
         e = new ArrayLengthExp(e->loc, e);
         e->type = Type::tsize_t;
         return e;
index 64cc42d9ce9b48a6643c5d3834a6a4669a6df3a6..ccf141ebb09b37fdd511826e21a4d40232001dc3 100644 (file)
@@ -95,6 +95,8 @@ public:
             s->exp = semantic(s->exp, sc);
             s->exp = resolveProperties(sc, s->exp);
             s->exp = s->exp->addDtorHook(sc);
+            if (checkNonAssignmentArrayOp(s->exp))
+                s->exp = new ErrorExp();
             if (FuncDeclaration *f = isFuncAddress(s->exp))
             {
                 if (f->checkForwardRef(s->exp->loc))
@@ -370,6 +372,8 @@ public:
 
         ds->condition = semantic(ds->condition, sc);
         ds->condition = resolveProperties(sc, ds->condition);
+        if (checkNonAssignmentArrayOp(ds->condition))
+            ds->condition = new ErrorExp();
         ds->condition = ds->condition->optimize(WANTvalue);
         ds->condition = checkGC(sc, ds->condition);
 
@@ -440,6 +444,8 @@ public:
 
             fs->condition = semantic(fs->condition, sc);
             fs->condition = resolveProperties(sc, fs->condition);
+            if (checkNonAssignmentArrayOp(fs->condition))
+                fs->condition = new ErrorExp();
             fs->condition = fs->condition->optimize(WANTvalue);
             fs->condition = checkGC(sc, fs->condition);
             fs->condition = fs->condition->toBoolean(sc);
@@ -450,6 +456,8 @@ public:
                 ((CommaExp *)fs->increment)->allowCommaExp = true;
             fs->increment = semantic(fs->increment, sc);
             fs->increment = resolveProperties(sc, fs->increment);
+            if (checkNonAssignmentArrayOp(fs->increment))
+                fs->increment = new ErrorExp();
             fs->increment = fs->increment->optimize(WANTvalue);
             fs->increment = checkGC(sc, fs->increment);
         }
@@ -1723,6 +1731,8 @@ public:
             ifs->condition = resolveProperties(sc, ifs->condition);
             ifs->condition = ifs->condition->addDtorHook(sc);
         }
+        if (checkNonAssignmentArrayOp(ifs->condition))
+            ifs->condition = new ErrorExp();
         ifs->condition = checkGC(sc, ifs->condition);
 
         // Convert to boolean after declaring prm so this works:
@@ -1971,6 +1981,8 @@ public:
                 break;
             }
         }
+        if (checkNonAssignmentArrayOp(ss->condition))
+            ss->condition = new ErrorExp();
         ss->condition = ss->condition->optimize(WANTvalue);
         ss->condition = checkGC(sc, ss->condition);
         if (ss->condition->op == TOKerror)
index 3a1a1e7e9840001c304b2cea21ce778eb3b5b82b..db2175048755ced9b67d1537d30768f6954c57bf 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-15  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+       PR d/90650
+       * gdc.dg/pr90650a.d: New test.
+       * gdc.dg/pr90650b.d: New test.
+
 2019-06-15  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        * gfortran.dg/dummy_derived_typed.f90: New test.
diff --git a/gcc/testsuite/gdc.dg/pr90650a.d b/gcc/testsuite/gdc.dg/pr90650a.d
new file mode 100644 (file)
index 0000000..57228ca
--- /dev/null
@@ -0,0 +1,14 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90650
+// { dg-do compile }
+class c
+{
+  static f ()
+  {
+    return 0;
+  }
+}
+
+void g ()
+{
+  if (0 & [0] & c.f()) {}   // { dg-error "array operation \\\[0\\\] & 0 & f\\(\\) without destination memory not allowed" }
+}
diff --git a/gcc/testsuite/gdc.dg/pr90650b.d b/gcc/testsuite/gdc.dg/pr90650b.d
new file mode 100644 (file)
index 0000000..2b3192e
--- /dev/null
@@ -0,0 +1,13 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90650
+// { dg-do compile }
+class c
+{
+  static f ()
+  {
+    return 0;
+  }
+}
+void g ()
+{
+  if ([0] & c.f()) {}   // { dg-error "array operation \\\[0\\\] & f\\(\\) without destination memory not allowed" }
+}