]> granicus.if.org Git - clang/commitdiff
Relax assertion in CFG builder when processing ForStmts. This fixes an assertion...
authorTed Kremenek <kremenek@apple.com>
Wed, 15 Sep 2010 07:01:20 +0000 (07:01 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 15 Sep 2010 07:01:20 +0000 (07:01 +0000)
on code containing GNU statement expressions reported in PR 8141.

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

lib/Analysis/CFG.cpp
test/Analysis/misc-ps.m

index e297ec4856c376d74840519468b09253df2d04bf..cc3a38886267ff7f93790eda81ff4977d3315911 100644 (file)
@@ -991,7 +991,8 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
   if (Stmt* C = F->getCond()) {
     Block = ExitConditionBlock;
     EntryConditionBlock = addStmt(C);
-    assert(Block == EntryConditionBlock);
+    assert(Block == EntryConditionBlock ||
+           (Block == 0 && EntryConditionBlock == Succ));
 
     // If this block contains a condition variable, add both the condition
     // variable and initializer to the CFG.
index a44eb0c18d33f6ad66d0aefd228ebd791be9fd97..bb70c90e6a62276f8d36b33ac62ef7ec2446d441 100644 (file)
@@ -1129,3 +1129,9 @@ void rdar6351970_c() {
 }
 @end
 
+// PR 8149 - GNU statement expression in condition of ForStmt.
+// This previously triggered an assertion failure in CFGBuilder.
+void pr8149(void) {
+  for (; ({ do { } while (0); 0; });) { }
+}
+