pr39154.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* PR middle-end/39154 */
  2. /* { dg-do compile } */
  3. /* { dg-options "-O2 -std=gnu99" } */
  4. extern void abort (void);
  5. int n = 20;
  6. int
  7. main (void)
  8. {
  9. int a[n], b[n][n];
  10. #pragma omp parallel for
  11. for (int i = 0; i < n; i++)
  12. {
  13. a[i] = i + 1;
  14. #pragma omp parallel for
  15. for (int j = 0; j < n; j++)
  16. b[i][j] = a[i];
  17. }
  18. for (int i = 0; i < n; i++)
  19. {
  20. for (int j = 0; j < n; j++)
  21. if (b[i][j] != i + 1)
  22. abort ();
  23. if (a[i] != i + 1)
  24. abort ();
  25. }
  26. #pragma omp parallel for shared (n, a, b)
  27. for (int i = 0; i < n; i++)
  28. {
  29. a[i] = i + 3;
  30. #pragma omp parallel for
  31. for (int j = 0; j < n; j++)
  32. b[i][j] = a[i];
  33. }
  34. for (int i = 0; i < n; i++)
  35. {
  36. for (int j = 0; j < n; j++)
  37. if (b[i][j] != i + 3)
  38. abort ();
  39. if (a[i] != i + 3)
  40. abort ();
  41. }
  42. #pragma omp parallel for
  43. for (int i = 0; i < n; i++)
  44. {
  45. a[i] = i + 5;
  46. #pragma omp parallel for shared (n, a, b)
  47. for (int j = 0; j < n; j++)
  48. b[i][j] = a[i];
  49. }
  50. for (int i = 0; i < n; i++)
  51. {
  52. for (int j = 0; j < n; j++)
  53. if (b[i][j] != i + 5)
  54. abort ();
  55. if (a[i] != i + 5)
  56. abort ();
  57. }
  58. #pragma omp parallel for shared (n, a, b)
  59. for (int i = 0; i < n; i++)
  60. {
  61. a[i] = i + 7;
  62. #pragma omp parallel for shared (n, a, b)
  63. for (int j = 0; j < n; j++)
  64. b[i][j] = a[i];
  65. }
  66. for (int i = 0; i < n; i++)
  67. {
  68. for (int j = 0; j < n; j++)
  69. if (b[i][j] != i + 7)
  70. abort ();
  71. if (a[i] != i + 7)
  72. abort ();
  73. }
  74. #pragma omp parallel for private (a, b)
  75. for (int i = 0; i < n; i++)
  76. {
  77. a[i] = i + 1;
  78. #pragma omp parallel for
  79. for (int j = 0; j < n; j++)
  80. b[i][j] = a[i];
  81. }
  82. #pragma omp parallel for private (a, b)
  83. for (int i = 0; i < n; i++)
  84. {
  85. a[i] = i + 1;
  86. #pragma omp parallel for private (b)
  87. for (int j = 0; j < n; j++)
  88. b[i][j] = a[i];
  89. }
  90. return 0;
  91. }