loop-control.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. // RUN: %clang_cc1 -fsyntax-only -x c++ -Werror %s
  3. int pr8880_1() {
  4. int first = 1;
  5. for ( ; ({ if (first) { first = 0; continue; } 0; }); )
  6. return 0;
  7. return 1;
  8. }
  9. void pr8880_2(int first) {
  10. for ( ; ({ if (first) { first = 0; break; } 0; }); ) {}
  11. }
  12. void pr8880_3(int first) {
  13. for ( ; ; (void)({ if (first) { first = 0; continue; } 0; })) {}
  14. }
  15. void pr8880_4(int first) {
  16. for ( ; ; (void)({ if (first) { first = 0; break; } 0; })) {}
  17. }
  18. void pr8880_5 (int first) {
  19. while(({ if (first) { first = 0; continue; } 0; })) {}
  20. }
  21. void pr8880_6 (int first) {
  22. while(({ if (first) { first = 0; break; } 0; })) {}
  23. }
  24. void pr8880_7 (int first) {
  25. do {} while(({ if (first) { first = 0; continue; } 0; }));
  26. }
  27. void pr8880_8 (int first) {
  28. do {} while(({ if (first) { first = 0; break; } 0; }));
  29. }
  30. void pr8880_10(int i) {
  31. for ( ; i != 10 ; i++ )
  32. for ( ; ; (void)({ ++i; continue; i;})) {} // expected-warning{{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
  33. }
  34. void pr8880_11(int i) {
  35. for ( ; i != 10 ; i++ )
  36. for ( ; ; (void)({ ++i; break; i;})) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}}
  37. }
  38. void pr8880_12(int i, int j) {
  39. for ( ; i != 10 ; i++ )
  40. for ( ; ({if (i) continue; i;}); j++) {} // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
  41. }
  42. void pr8880_13(int i, int j) {
  43. for ( ; i != 10 ; i++ )
  44. for ( ; ({if (i) break; i;}); j++) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}}
  45. }
  46. void pr8880_14(int i) {
  47. for ( ; i != 10 ; i++ )
  48. while(({if (i) break; i;})) {} // expected-warning {{'break' is bound to current loop, GCC binds it to the enclosing loop}}
  49. }
  50. void pr8880_15(int i) {
  51. while (--i)
  52. while(({if (i) continue; i;})) {} // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
  53. }
  54. void pr8880_16(int i) {
  55. for ( ; i != 10 ; i++ )
  56. do {} while(({if (i) break; i;})); // expected-warning {{'break' is bound to current loop, GCC binds it to the enclosing loop}}
  57. }
  58. void pr8880_17(int i) {
  59. for ( ; i != 10 ; i++ )
  60. do {} while(({if (i) continue; i;})); // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
  61. }
  62. void pr8880_18(int x, int y) {
  63. while(x > 0)
  64. switch(({if(y) break; y;})) {
  65. case 2: x = 0;
  66. }
  67. }
  68. void pr8880_19(int x, int y) {
  69. switch(x) {
  70. case 1:
  71. switch(({if(y) break; y;})) {
  72. case 2: x = 0;
  73. }
  74. }
  75. }
  76. void pr8880_20(int x, int y) {
  77. switch(x) {
  78. case 1:
  79. while(({if (y) break; y;})) {} //expected-warning {{'break' is bound to loop, GCC binds it to switch}}
  80. }
  81. }
  82. void pr8880_21(int x, int y) {
  83. switch(x) {
  84. case 1:
  85. do {} while(({if (y) break; y;})); //expected-warning {{'break' is bound to loop, GCC binds it to switch}}
  86. }
  87. }
  88. void pr8880_22(int x, int y) {
  89. switch(x) {
  90. case 1:
  91. for ( ; ; (void)({ ++y; break; y;})) {} // expected-warning{{'break' is bound to loop, GCC binds it to switc}}
  92. }
  93. }
  94. void pr8880_23(int x, int y) {
  95. switch(x) {
  96. case 1:
  97. for ( ; ({ ++y; break; y;}); ++y) {} // expected-warning{{'break' is bound to loop, GCC binds it to switch}}
  98. }
  99. }