diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 276406c7696..4676645f971 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-fe5f388d8e5d97dccaa4ef1349f931c36a2cbc46
+e49192807967c6f11252683a731c5a0159ef36da
 
 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/func.c b/gcc/d/dmd/func.c
index f8e9601dbec..dbc5fa6352c 100644
--- a/gcc/d/dmd/func.c
+++ b/gcc/d/dmd/func.c
@@ -30,7 +30,7 @@
 #include "visitor.h"
 #include "objc.h"
 
-Expression *addInvariant(Loc loc, Scope *sc, AggregateDeclaration *ad, VarDeclaration *vthis, bool direct);
+Expression *addInvariant(AggregateDeclaration *ad, VarDeclaration *vthis);
 bool checkReturnEscape(Scope *sc, Expression *e, bool gag);
 bool checkReturnEscapeRef(Scope *sc, Expression *e, bool gag);
 bool checkNestedRef(Dsymbol *s, Dsymbol *p);
@@ -1648,7 +1648,7 @@ void FuncDeclaration::semantic3(Scope *sc)
         Statement *fpreinv = NULL;
         if (addPreInvariant())
         {
-            Expression *e = addInvariant(loc, sc, ad, vthis, isDtorDeclaration() != NULL);
+            Expression *e = addInvariant(ad, vthis);
             if (e)
                 fpreinv = new ExpStatement(Loc(), e);
         }
@@ -1657,7 +1657,7 @@ void FuncDeclaration::semantic3(Scope *sc)
         Statement *fpostinv = NULL;
         if (addPostInvariant())
         {
-            Expression *e = addInvariant(loc, sc, ad, vthis, isCtorDeclaration() != NULL);
+            Expression *e = addInvariant(ad, vthis);
             if (e)
                 fpostinv = new ExpStatement(Loc(), e);
         }
@@ -4154,67 +4154,47 @@ bool FuncDeclaration::addPostInvariant()
  * Input:
  *      ad      aggregate with the invariant
  *      vthis   variable with 'this'
- *      direct  call invariant directly
  * Returns:
  *      void expression that calls the invariant
  */
-Expression *addInvariant(Loc loc, Scope *sc, AggregateDeclaration *ad, VarDeclaration *vthis, bool direct)
+Expression *addInvariant(AggregateDeclaration *ad, VarDeclaration *vthis)
 {
     Expression *e = NULL;
-    if (direct)
-    {
-        // Call invariant directly only if it exists
-        FuncDeclaration *inv = ad->inv;
-        ClassDeclaration *cd = ad->isClassDeclaration();
 
-        while (!inv && cd)
-        {
-            cd = cd->baseClass;
-            if (!cd)
-                break;
-            inv = cd->inv;
-        }
-        if (inv)
-        {
-        #if 1
-            // Workaround for bugzilla 13394: For the correct mangling,
-            // run attribute inference on inv if needed.
-            inv->functionSemantic();
-        #endif
-
-            //e = new DsymbolExp(Loc(), inv);
-            //e = new CallExp(Loc(), e);
-            //e = e->semantic(sc2);
-
-            /* Bugzilla 13113: Currently virtual invariant calls completely
-             * bypass attribute enforcement.
-             * Change the behavior of pre-invariant call by following it.
-             */
-            e = new ThisExp(Loc());
-            e->type = vthis->type;
-            e = new DotVarExp(Loc(), e, inv, false);
-            e->type = inv->type;
-            e = new CallExp(Loc(), e);
-            e->type = Type::tvoid;
-        }
+    // Call invariant directly only if it exists
+    FuncDeclaration *inv = ad->inv;
+    ClassDeclaration *cd = ad->isClassDeclaration();
+
+    while (!inv && cd)
+    {
+        cd = cd->baseClass;
+        if (!cd)
+            break;
+        inv = cd->inv;
     }
-    else
+    if (inv)
     {
     #if 1
         // Workaround for bugzilla 13394: For the correct mangling,
         // run attribute inference on inv if needed.
-        if (ad->isStructDeclaration() && ad->inv)
-            ad->inv->functionSemantic();
+        inv->functionSemantic();
     #endif
 
-        // Call invariant virtually
-        Expression *v = new ThisExp(Loc());
-        v->type = vthis->type;
-        if (ad->isStructDeclaration())
-            v = v->addressOf();
-        e = new StringExp(Loc(), const_cast<char *>("null this"));
-        e = new AssertExp(loc, v, e);
-        e = semantic(e, sc);
+        //e = new DsymbolExp(Loc(), inv);
+        //e = new CallExp(Loc(), e);
+        //e = e->semantic(sc2);
+
+        /* https://issues.dlang.org/show_bug.cgi?id=13113
+         * Currently virtual invariant calls completely
+         * bypass attribute enforcement.
+         * Change the behavior of pre-invariant call by following it.
+         */
+        e = new ThisExp(Loc());
+        e->type = vthis->type;
+        e = new DotVarExp(Loc(), e, inv, false);
+        e->type = inv->type;
+        e = new CallExp(Loc(), e);
+        e->type = Type::tvoid;
     }
     return e;
 }
diff --git a/gcc/d/dmd/statementsem.c b/gcc/d/dmd/statementsem.c
index 90493475fff..42f885d4175 100644
--- a/gcc/d/dmd/statementsem.c
+++ b/gcc/d/dmd/statementsem.c
@@ -1188,7 +1188,9 @@ public:
                     }
 
                     // T value = tmp[key];
-                    fs->value->_init = new ExpInitializer(loc, new IndexExp(loc, new VarExp(loc, tmp), new VarExp(loc, fs->key)));
+                    IndexExp *indexExp = new IndexExp(loc, new VarExp(loc, tmp), new VarExp(loc, fs->key));
+                    indexExp->indexIsInBounds = true; // disabling bounds checking in foreach statements.
+                    fs->value->_init = new ExpInitializer(loc, indexExp);
                     Statement *ds = new ExpStatement(loc, fs->value);
 
                     if (dim == 2)
