[ELF] Linkerscript: fixed bug about commands processing.

It was possible situation about some commands just were not processed
(were skipped) because of a bug appeared when constraint checking used.

Testcase is attached.

llvm-svn: 281818
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 7c1e2dd..d6f406e 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -297,6 +297,7 @@
         for (InputSectionBase<ELFT> *S : V)
           S->OutSec = nullptr;
         Opt.Commands.erase(Iter);
+        --I;
         continue;
       }
 
diff --git a/lld/test/ELF/linkerscript/sections-constraint4.s b/lld/test/ELF/linkerscript/sections-constraint4.s
new file mode 100644
index 0000000..6c2d4c8
--- /dev/null
+++ b/lld/test/ELF/linkerscript/sections-constraint4.s
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { \
+# RUN:  .foo : ONLY_IF_RO { *(.foo) } \
+# RUN:  .bar : {bar1 = .; *(.bar) } }" > %t1.script
+# RUN: ld.lld -o %t1 --script %t1.script %t
+# RUN: llvm-readobj -t %t1 | FileCheck %s
+
+# CHECK: Name: bar1
+
+.global _start
+_start:
+  nop
+
+.section .bar, "aw"
+bar:
+ .long 1
+
+.section .foo, "aw"
+ .long 0