[C++11] Fix break due to MSVC bug.
authorAhmed Charles <ahmedcharles@gmail.com>
Sun, 9 Mar 2014 04:57:09 +0000 (04:57 +0000)
committerAhmed Charles <ahmedcharles@gmail.com>
Sun, 9 Mar 2014 04:57:09 +0000 (04:57 +0000)
MSVC (2012, 2013, 2013 Nov CTP) fail on the following code:

int main() {
  int arr[] = {1, 2};
  for (int i : arr)
    do {} while (0);
}

The fix is to put {} around the for loop. I've reported this to the MSVC
team.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203371 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Verifier.cpp

index f64ebc1a672a15bc023350b7186b48e2964b0cf6..f49cca5a3e3d030b941083f8ea182e0316f7ec23 100644 (file)
@@ -1974,9 +1974,10 @@ void Verifier::visitInstruction(Instruction &I) {
   Assert1(BB, "Instruction not embedded in basic block!", &I);
 
   if (!isa<PHINode>(I)) {   // Check that non-phi nodes are not self referential
-    for (User *U : I.users())
+    for (User *U : I.users()) {
       Assert1(U != (User*)&I || !DT.isReachableFromEntry(BB),
               "Only PHI nodes may reference their own value!", &I);
+    }
   }
 
   // Check that void typed values don't have names