https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100999
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Iain Buclaw <ibuc...@gcc.gnu.org>: https://gcc.gnu.org/g:a30552af7073aba16af6798a1e6cd0a345b06586 commit r11-8553-ga30552af7073aba16af6798a1e6cd0a345b06586 Author: Iain Buclaw <ibuc...@gdcproject.org> Date: Fri Jun 11 19:33:07 2021 +0200 d: foreach over a tuple doesn't work on 16-bit targets (PR100999) Improves semantic passes in the front-end around the `foreach' and `static foreach' statements to be more resilient to compiling in a minimal D runtime environment. Checking of the index type has been improved as well so now there won't be needless compiler errors when using 8 or 16-bit integers as index types when the size fits the expected loop range. gcc/d/ChangeLog: PR d/100999 * dmd/cond.c (lowerArrayAggregate): Run CTFE interpret on foreach input range. (createTupleType): Don't generate typeinfo when disabled. (lowerNonArrayAggregate): Suppress errors when running type semantic. (staticForeachPrepare): Don't run CTFE interpret from here. * dmd/dinterpret.c (ctfeInterpret): Add more shortcut cases. * dmd/expression.c (Expression::checkPostblit): Don't generate typeinfo when type is missing from library. * dmd/expressionsem.c (resolvePropertiesX): Remove early error. * dmd/statementsem.c (StatementSemanticVisitor::declareVariable): Don't override index type. (StatementSemanticVisitor::makeTupleForeachBody): Check index type is integral and index range fits type size. (StatementSemanticVisitor::visit (ForeachStatement*)): Adjust index range before testing. libphobos/ChangeLog: PR d/100999 * src/std/typecons.d (template Proxy): Check for field or property functions as the else branch. gcc/testsuite/ChangeLog: PR d/100999 * gdc.test/compilable/staticforeach.d: Add new tests. * gdc.test/fail_compilation/diag16976.d: Likewise. * gdc.test/fail_compilation/fail117.d: Likewise. * gdc.test/fail_compilation/fail238_m32.d: Likewise. * gdc.test/fail_compilation/fail238_m64.d: Likewise. * gdc.test/fail_compilation/fail7424b.d: Likewise. * gdc.test/fail_compilation/fail7424c.d: Likewise. * gdc.test/fail_compilation/fail7424d.d: Likewise. * gdc.test/fail_compilation/fail7424e.d: Likewise. * gdc.test/fail_compilation/fail7424f.d: Likewise. * gdc.test/fail_compilation/fail7424g.d: Likewise. * gdc.test/fail_compilation/fail7424h.d: Likewise. * gdc.test/fail_compilation/fail7424i.d: Likewise. * gdc.test/fail_compilation/fail9766.d: Likewise. * gdc.test/fail_compilation/ice9406.d: Likewise. * gdc.test/compilable/extra-files/minimal/object.d: New file. * gdc.test/compilable/interpret5.d: New test. * gdc.test/compilable/minimal3.d: New test. * gdc.test/compilable/test21742.d: New test. * gdc.test/compilable/test22006.d: New test. * gdc.test/fail_compilation/b12504.d: New test. * gdc.test/fail_compilation/fail22006.d: New test. * gdc.test/fail_compilation/test21927.d: New test. * gdc.test/fail_compilation/test21939.d: New test. (cherry picked from commit 68f46862d33707450bdf70cfddd91ae2a12527a8)