13d7c780d93ebcb84a1224de8c44835ea43e82b15Eli Friedman// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
2a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel
3a2c534223dc6b81685d1323fedca53c54918bb66Devang Patelint bar();
41e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattnerint test0() {
5a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  int i;
6a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  i = 1 + 2;
7a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  do {
8a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    i = bar();
9a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    i = bar();
10a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  } while(0);
11a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  return i;
12a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel}
13a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel
14a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel
151e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattnerint test1() {
16a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  int i;
17a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  i = 1 + 2;
18a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  do {
19a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    i = bar();
20a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    if (i == 42)
21a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel      break;
22a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    i = bar();
23a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  } while(1);
24a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  return i;
25a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel}
26a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel
27a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel
281e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattnerint test2() {
29a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  int i;
30a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  i = 1 + 2;
31a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  do {
32a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    i = bar();
33a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    if (i == 42)
34a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel      continue;
35a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    i = bar();
36a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  } while(1);
37a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  return i;
38a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel}
39a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel
40a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel
411e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattnerint test3() {
42a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  int i;
43a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  i = 1 + 2;
44a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  do {
45a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    i = bar();
46a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    if (i == 42)
47a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel      break;
48a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  } while(0);
49a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  return i;
50a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel}
51a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel
52a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel
531e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattnerint test4() {
54a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  int i;
55a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  i = 1 + 2;
56a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  do {
57a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    i = bar();
58a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel    if (i == 42)
59a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel      continue;
60a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  } while(0);
61a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel  return i;
62a2c534223dc6b81685d1323fedca53c54918bb66Devang Patel}
631e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattner
641e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattner// rdar://6103124
651e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattnervoid test5() {
661e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattner  do { break; } while(0);
671e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattner}
681e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattner
693d7c780d93ebcb84a1224de8c44835ea43e82b15Eli Friedman// PR14191
703d7c780d93ebcb84a1224de8c44835ea43e82b15Eli Friedmanvoid test6f(void);
713d7c780d93ebcb84a1224de8c44835ea43e82b15Eli Friedmanvoid test6() {
723d7c780d93ebcb84a1224de8c44835ea43e82b15Eli Friedman  do {
733d7c780d93ebcb84a1224de8c44835ea43e82b15Eli Friedman  } while (test6f(), 0);
747b82cfc1ba1ee7000273e81e1e4c791fff0e22e5Eli Friedman  // CHECK: call void @test6f()
753d7c780d93ebcb84a1224de8c44835ea43e82b15Eli Friedman}
761e9660e1fb11efb7e65799bc145c0e2b6f3562beChris Lattner
77