79_vla_continue.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #include <stdio.h>
  2. int f(void)
  3. {
  4. return 5;
  5. }
  6. void test1()
  7. {
  8. int count = 10;
  9. void *addr[10];
  10. for(;count--;) {
  11. int a[f()];
  12. addr[count] = a;
  13. continue;
  14. }
  15. if(addr[9] == addr[0]) {
  16. printf("OK\n");
  17. } else {
  18. printf("NOT OK\n");
  19. }
  20. }
  21. void test2()
  22. {
  23. int count = 10;
  24. void *addr[count];
  25. for(;count--;) {
  26. int a[f()];
  27. addr[count] = a;
  28. continue;
  29. }
  30. if(addr[9] == addr[0]) {
  31. printf("OK\n");
  32. } else {
  33. printf("NOT OK\n");
  34. }
  35. }
  36. void test3()
  37. {
  38. int count = 10;
  39. void *addr[count];
  40. while(count--) {
  41. int a[f()];
  42. addr[count] = a;
  43. continue;
  44. }
  45. if(addr[9] == addr[0]) {
  46. printf("OK\n");
  47. } else {
  48. printf("NOT OK\n");
  49. }
  50. }
  51. void test4()
  52. {
  53. int count = 10;
  54. void *addr[count];
  55. do {
  56. int a[f()];
  57. addr[--count] = a;
  58. continue;
  59. } while (count);
  60. if(addr[9] == addr[0]) {
  61. printf("OK\n");
  62. } else {
  63. printf("NOT OK\n");
  64. }
  65. }
  66. void test5()
  67. {
  68. int count = 10;
  69. int a[f()];
  70. int c[f()];
  71. c[0] = 42;
  72. for(;count--;) {
  73. int b[f()];
  74. int i;
  75. for (i=0; i<f(); i++) {
  76. b[i] = count;
  77. }
  78. }
  79. if (c[0] == 42) {
  80. printf("OK\n");
  81. } else {
  82. printf("NOT OK\n");
  83. }
  84. }
  85. int main(void)
  86. {
  87. test1();
  88. test2();
  89. test3();
  90. test4();
  91. test5();
  92. return 0;
  93. }