From: Iain Buclaw Date: Sun, 16 Jun 2019 07:48:53 +0000 (+0000) Subject: re PR d/90650 (ICE in fold_convert_loc, at fold-const.c:2552) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a1543fb19ba17a455b0e9df5e373a1643082f5d2;p=gcc.git re PR d/90650 (ICE in fold_convert_loc, at fold-const.c:2552) 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 PR d/90650 * gdc.dg/pr90650a.d: New test. * gdc.dg/pr90650b.d: New test. From-SVN: r272344 --- diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 4cb2bbac46d..7258fadb1bb 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -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. diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c index 19b7ccb7236..ebdfae584c8 100644 --- a/gcc/d/dmd/expressionsem.c +++ b/gcc/d/dmd/expressionsem.c @@ -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())) { diff --git a/gcc/d/dmd/mtype.c b/gcc/d/dmd/mtype.c index 058738ec825..2562f364b49 100644 --- a/gcc/d/dmd/mtype.c +++ b/gcc/d/dmd/mtype.c @@ -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; diff --git a/gcc/d/dmd/statementsem.c b/gcc/d/dmd/statementsem.c index 64cc42d9ce9..ccf141ebb09 100644 --- a/gcc/d/dmd/statementsem.c +++ b/gcc/d/dmd/statementsem.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3a1a1e7e984..db217504875 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-06-15 Iain Buclaw + + PR d/90650 + * gdc.dg/pr90650a.d: New test. + * gdc.dg/pr90650b.d: New test. + 2019-06-15 Steven G. Kargl * 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 index 00000000000..57228cab19f --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr90650a.d @@ -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 index 00000000000..2b3192ed2b6 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr90650b.d @@ -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" } +}