switch.frag 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #version 300 es
  2. precision highp float;
  3. uniform int c, d;
  4. in highp float x;
  5. void main()
  6. {
  7. float f;
  8. int a[2];
  9. switch(f) { // ERROR
  10. }
  11. switch(a) { // ERROR
  12. }
  13. switch(c)
  14. {
  15. }
  16. switch(c) // WARNING, not enough stuff after last label
  17. {
  18. case 2:
  19. }
  20. switch(c)
  21. {
  22. f = sin(x); // ERRROR
  23. case 2:
  24. f = cos(x);
  25. break;
  26. }
  27. switch (c) {
  28. default:
  29. break;
  30. case 1:
  31. f = sin(x);
  32. break;
  33. case 2:
  34. f = cos(x);
  35. break;
  36. default: // ERROR, 2nd default
  37. f = tan(x);
  38. }
  39. switch (c) {
  40. case 1:
  41. f = sin(x);
  42. break;
  43. case 2:
  44. switch (d) {
  45. case 1:
  46. f = x * x * x;
  47. break;
  48. case 2:
  49. f = x * x;
  50. break;
  51. }
  52. break;
  53. default:
  54. f = tan(x);
  55. case 1: // ERROR, 2nd 'case 1'
  56. break;
  57. case 3.8: // ERROR, non-int
  58. break;
  59. case c: // ERROR, non-constant
  60. break;
  61. }
  62. switch (c) { // a no-error normal switch
  63. case 1:
  64. f = sin(x);
  65. break;
  66. case 2:
  67. switch (d) {
  68. case 1:
  69. f = x * x * x;
  70. break;
  71. case 2:
  72. f = x * x;
  73. break;
  74. }
  75. break;
  76. default:
  77. f = tan(x);
  78. }
  79. break; // ERROR
  80. switch (c) {
  81. case 1:
  82. f = sin(x);
  83. break;
  84. case 2:
  85. switch (d) {
  86. case 1:
  87. {
  88. case 4: // ERROR
  89. break;
  90. }
  91. f = x * x * x;
  92. if (c < d) {
  93. case 2: // ERROR
  94. f = x * x;
  95. }
  96. if (d < c)
  97. case 3: // ERROR
  98. break;
  99. }
  100. break;
  101. case 4:
  102. f = tan(x);
  103. if (f < 0.0)
  104. default: // ERROR
  105. break;
  106. }
  107. case 5: // ERROR
  108. default: // ERROR
  109. switch (0) {
  110. default:
  111. int onlyInSwitch = 0;
  112. }
  113. onlyInSwitch; // ERROR
  114. switch (0) {
  115. default:
  116. int x; // WARNING (was "no statement" ERROR, but spec. changed because unclear what a statement is)
  117. }
  118. switch (c) {
  119. case 1:
  120. {
  121. int nestedX;
  122. break;
  123. }
  124. case 2:
  125. nestedX; // ERROR
  126. int nestedZ;
  127. float a; // okay, hiding outer 'a'
  128. break;
  129. case 3:
  130. int linearZ;
  131. break;
  132. break;
  133. case 4:
  134. int linearY = linearZ;
  135. break;
  136. case 5: // okay that branch bypassed an initializer
  137. const int linearC = 4;
  138. break;
  139. case 6: // okay that branch bypassed an initializer
  140. linearC;
  141. }
  142. nestedZ; // ERROR, no longer in scope
  143. }