adlint 3.0.10 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/ChangeLog +67 -0
  2. data/MANIFEST +2 -0
  3. data/NEWS +10 -3
  4. data/etc/mesg.d/c_builtin/en_US/messages.yml +29 -1
  5. data/etc/mesg.d/c_builtin/ja_JP/messages.yml +29 -1
  6. data/etc/mesg.d/core/en_US/messages.yml +1 -1
  7. data/etc/mesg.d/core/ja_JP/messages.yml +1 -1
  8. data/features/code_check/W0003.feature +5 -0
  9. data/features/code_check/W0023.feature +32 -0
  10. data/features/code_check/W0024.feature +22 -0
  11. data/features/code_check/W0093.feature +71 -0
  12. data/features/code_check/W0097.feature +4 -0
  13. data/features/code_check/W0100.feature +10 -0
  14. data/features/code_check/W0119.feature +8 -0
  15. data/features/code_check/W0133.feature +8 -0
  16. data/features/code_check/W0134.feature +8 -0
  17. data/features/code_check/W0136.feature +8 -0
  18. data/features/code_check/W0138.feature +8 -0
  19. data/features/code_check/W0140.feature +8 -0
  20. data/features/code_check/W0142.feature +8 -0
  21. data/features/code_check/W0143.feature +8 -0
  22. data/features/code_check/W0144.feature +8 -0
  23. data/features/code_check/W0145.feature +8 -0
  24. data/features/code_check/W0146.feature +8 -0
  25. data/features/code_check/W0147.feature +8 -0
  26. data/features/code_check/W0148.feature +8 -0
  27. data/features/code_check/W0149.feature +8 -0
  28. data/features/code_check/W0150.feature +8 -0
  29. data/features/code_check/W0151.feature +8 -0
  30. data/features/code_check/W0152.feature +8 -0
  31. data/features/code_check/W0153.feature +8 -0
  32. data/features/code_check/W0154.feature +8 -0
  33. data/features/code_check/W0155.feature +8 -0
  34. data/features/code_check/W0156.feature +8 -0
  35. data/features/code_check/W0157.feature +8 -0
  36. data/features/code_check/W0158.feature +8 -0
  37. data/features/code_check/W0159.feature +8 -0
  38. data/features/code_check/W0160.feature +8 -0
  39. data/features/code_check/W0161.feature +8 -0
  40. data/features/code_check/W0162.feature +8 -0
  41. data/features/code_check/W0163.feature +8 -0
  42. data/features/code_check/W0164.feature +8 -0
  43. data/features/code_check/W0165.feature +8 -0
  44. data/features/code_check/W0166.feature +8 -0
  45. data/features/code_check/W0167.feature +8 -0
  46. data/features/code_check/W0168.feature +8 -0
  47. data/features/code_check/W0169.feature +8 -0
  48. data/features/code_check/W0170.feature +8 -0
  49. data/features/code_check/W0171.feature +8 -0
  50. data/features/code_check/W0172.feature +8 -0
  51. data/features/code_check/W0173.feature +8 -0
  52. data/features/code_check/W0174.feature +8 -0
  53. data/features/code_check/W0175.feature +8 -0
  54. data/features/code_check/W0176.feature +8 -0
  55. data/features/code_check/W0177.feature +8 -0
  56. data/features/code_check/W0178.feature +8 -0
  57. data/features/code_check/W0179.feature +8 -0
  58. data/features/code_check/W0180.feature +8 -0
  59. data/features/code_check/W0181.feature +8 -0
  60. data/features/code_check/W0250.feature +8 -0
  61. data/features/code_check/W0422.feature +194 -0
  62. data/features/code_check/W0459.feature +16 -0
  63. data/features/code_check/W0460.feature +342 -0
  64. data/features/code_check/W0461.feature +5 -0
  65. data/features/code_check/W0497.feature +12 -0
  66. data/features/code_check/W0499.feature +6 -0
  67. data/features/code_check/W0502.feature +6 -0
  68. data/features/code_check/W0570.feature +47 -0
  69. data/features/code_check/W0573.feature +8 -0
  70. data/features/code_check/W0582.feature +4 -0
  71. data/features/code_check/W0583.feature +4 -0
  72. data/features/code_check/W0584.feature +10 -0
  73. data/features/code_check/W0599.feature +10 -0
  74. data/features/code_check/W0644.feature +2 -0
  75. data/features/code_check/W0649.feature +14 -0
  76. data/features/code_check/W0650.feature +12 -0
  77. data/features/code_check/W0685.feature +10 -0
  78. data/features/code_check/W0686.feature +8 -0
  79. data/features/code_check/W0711.feature +2 -0
  80. data/features/code_check/W0712.feature +2 -0
  81. data/features/code_check/W0713.feature +2 -0
  82. data/features/code_check/W0714.feature +2 -0
  83. data/features/code_check/W0715.feature +2 -0
  84. data/features/code_check/W0718.feature +2 -0
  85. data/features/code_check/W0719.feature +8 -0
  86. data/features/code_check/W0732.feature +18 -0
  87. data/features/code_check/W0733.feature +18 -0
  88. data/features/code_check/W0734.feature +24 -0
  89. data/features/code_check/W0735.feature +24 -0
  90. data/features/code_check/W0747.feature +8 -0
  91. data/features/code_check/W0749.feature +8 -0
  92. data/features/code_check/W0750.feature +8 -0
  93. data/features/code_check/W0753.feature +8 -0
  94. data/features/code_check/W0754.feature +8 -0
  95. data/features/code_check/W0759.feature +8 -0
  96. data/features/code_check/W0760.feature +8 -0
  97. data/features/code_check/W0761.feature +8 -0
  98. data/features/code_check/W0762.feature +8 -0
  99. data/features/code_check/W0794.feature +6 -0
  100. data/features/code_check/W1050.feature +8 -0
  101. data/features/code_check/W1066.feature +8 -0
  102. data/features/code_check/W1067.feature +8 -0
  103. data/features/code_check/W1068.feature +8 -0
  104. data/features/code_check/W1071.feature +4 -0
  105. data/features/code_check/W9003.feature +2 -0
  106. data/lib/adlint/cc1.rb +1 -0
  107. data/lib/adlint/cc1/branch.rb +34 -13
  108. data/lib/adlint/cc1/conv.rb +3 -3
  109. data/lib/adlint/cc1/ctrlexpr.rb +12 -7
  110. data/lib/adlint/cc1/environ.rb +12 -2
  111. data/lib/adlint/cc1/expr.rb +10 -8
  112. data/lib/adlint/cc1/interp.rb +56 -49
  113. data/lib/adlint/cc1/mediator.rb +9 -5
  114. data/lib/adlint/cc1/object.rb +37 -34
  115. data/lib/adlint/cc1/trace.rb +287 -0
  116. data/lib/adlint/cc1/type.rb +15 -15
  117. data/lib/adlint/cc1/value.rb +823 -427
  118. data/lib/adlint/cpp/eval.rb +5 -2
  119. data/lib/adlint/cpp/source.rb +21 -22
  120. data/lib/adlint/exam/c_builtin/cc1_check.rb +1636 -1067
  121. data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +28 -22
  122. data/lib/adlint/exam/c_builtin/cc1_code.rb +4 -4
  123. data/lib/adlint/exam/c_builtin/cc1_metric.rb +14 -14
  124. data/lib/adlint/location.rb +5 -7
  125. data/lib/adlint/metric.rb +2 -2
  126. data/lib/adlint/prelude.rb +6 -2
  127. data/lib/adlint/report.rb +2 -2
  128. data/lib/adlint/version.rb +3 -3
  129. data/share/doc/developers_guide_ja.html +10 -4
  130. data/share/doc/developers_guide_ja.texi +8 -2
  131. data/share/doc/users_guide_en.html +679 -72
  132. data/share/doc/users_guide_en.texi +557 -12
  133. data/share/doc/users_guide_ja.html +678 -74
  134. data/share/doc/users_guide_ja.texi +554 -13
  135. data/spec/adlint/cc1/ctrlexpr_spec.rb +20 -11
  136. data/spec/adlint/cc1/domain_spec.rb +9 -0
  137. metadata +4 -2
@@ -32,6 +32,8 @@ Feature: W0754
32
32
  | mesg | line | column |
33
33
  | W0117 | 1 | 6 |
34
34
  | W1049 | 3 | 15 |
35
+ | C1000 | | |
36
+ | C1006 | 1 | 15 |
35
37
  | W0100 | 3 | 11 |
36
38
  | W0104 | 1 | 15 |
37
39
  | W0628 | 1 | 6 |
@@ -68,6 +70,8 @@ Feature: W0754
68
70
  | mesg | line | column |
69
71
  | W0117 | 1 | 6 |
70
72
  | W1049 | 4 | 9 |
73
+ | C1000 | | |
74
+ | C1006 | 1 | 15 |
71
75
  | W0100 | 3 | 11 |
72
76
  | W0104 | 1 | 15 |
73
77
  | W0628 | 1 | 6 |
@@ -107,6 +111,8 @@ Feature: W0754
107
111
  | W0118 | 1 | 13 |
108
112
  | W0117 | 3 | 6 |
109
113
  | W1049 | 5 | 9 |
114
+ | C1000 | | |
115
+ | C1006 | 3 | 15 |
110
116
  | W0104 | 3 | 15 |
111
117
  | W0628 | 3 | 6 |
112
118
 
@@ -140,5 +146,7 @@ Feature: W0754
140
146
  | mesg | line | column |
141
147
  | W0117 | 1 | 7 |
142
148
  | W1049 | 3 | 12 |
149
+ | C1000 | | |
150
+ | C1006 | 1 | 16 |
143
151
  | W0104 | 1 | 16 |
144
152
  | W0628 | 1 | 7 |
@@ -33,6 +33,8 @@ Feature: W0759
33
33
  | mesg | line | column |
34
34
  | W0117 | 1 | 6 |
35
35
  | W1049 | 3 | 21 |
36
+ | C1000 | | |
37
+ | C1006 | 1 | 20 |
36
38
  | W0100 | 3 | 17 |
37
39
  | W0104 | 1 | 20 |
38
40
  | W0834 | 1 | 10 |
@@ -71,6 +73,8 @@ Feature: W0759
71
73
  | mesg | line | column |
72
74
  | W0117 | 1 | 6 |
73
75
  | W1049 | 4 | 9 |
76
+ | C1000 | | |
77
+ | C1006 | 1 | 20 |
74
78
  | W0100 | 3 | 17 |
75
79
  | W0104 | 1 | 20 |
76
80
  | W0834 | 1 | 10 |
@@ -112,6 +116,8 @@ Feature: W0759
112
116
  | W0118 | 1 | 13 |
113
117
  | W0117 | 3 | 6 |
114
118
  | W1049 | 5 | 9 |
119
+ | C1000 | | |
120
+ | C1006 | 3 | 20 |
115
121
  | W0104 | 3 | 20 |
116
122
  | W0834 | 3 | 10 |
117
123
  | W0628 | 3 | 6 |
@@ -147,6 +153,8 @@ Feature: W0759
147
153
  | mesg | line | column |
148
154
  | W0117 | 1 | 13 |
149
155
  | W1049 | 3 | 12 |
156
+ | C1000 | | |
157
+ | C1006 | 1 | 27 |
150
158
  | W0104 | 1 | 27 |
151
159
  | W0834 | 1 | 17 |
152
160
  | W0628 | 1 | 13 |
@@ -33,6 +33,8 @@ Feature: W0760
33
33
  | mesg | line | column |
34
34
  | W0117 | 1 | 6 |
35
35
  | W1049 | 3 | 15 |
36
+ | C1000 | | |
37
+ | C1006 | 1 | 20 |
36
38
  | W0100 | 3 | 11 |
37
39
  | W0104 | 1 | 20 |
38
40
  | W0834 | 1 | 10 |
@@ -71,6 +73,8 @@ Feature: W0760
71
73
  | mesg | line | column |
72
74
  | W0117 | 1 | 6 |
73
75
  | W1049 | 4 | 9 |
76
+ | C1000 | | |
77
+ | C1006 | 1 | 20 |
74
78
  | W0100 | 3 | 11 |
75
79
  | W0104 | 1 | 20 |
76
80
  | W0834 | 1 | 10 |
@@ -112,6 +116,8 @@ Feature: W0760
112
116
  | W0118 | 1 | 13 |
113
117
  | W0117 | 3 | 6 |
114
118
  | W1049 | 5 | 9 |
119
+ | C1000 | | |
120
+ | C1006 | 3 | 20 |
115
121
  | W0104 | 3 | 20 |
116
122
  | W0834 | 3 | 10 |
117
123
  | W0628 | 3 | 6 |
@@ -147,6 +153,8 @@ Feature: W0760
147
153
  | mesg | line | column |
148
154
  | W0117 | 1 | 7 |
149
155
  | W1049 | 3 | 12 |
156
+ | C1000 | | |
157
+ | C1006 | 1 | 21 |
150
158
  | W0104 | 1 | 21 |
151
159
  | W0834 | 1 | 11 |
152
160
  | W0628 | 1 | 7 |
@@ -33,6 +33,8 @@ Feature: W0761
33
33
  | mesg | line | column |
34
34
  | W0117 | 1 | 6 |
35
35
  | W1049 | 3 | 13 |
36
+ | C1000 | | |
37
+ | C1006 | 1 | 20 |
36
38
  | W0100 | 3 | 9 |
37
39
  | W0104 | 1 | 20 |
38
40
  | W0834 | 1 | 10 |
@@ -71,6 +73,8 @@ Feature: W0761
71
73
  | mesg | line | column |
72
74
  | W0117 | 1 | 6 |
73
75
  | W1049 | 4 | 9 |
76
+ | C1000 | | |
77
+ | C1006 | 1 | 20 |
74
78
  | W0100 | 3 | 9 |
75
79
  | W0104 | 1 | 20 |
76
80
  | W0834 | 1 | 10 |
@@ -112,6 +116,8 @@ Feature: W0761
112
116
  | W0118 | 1 | 13 |
113
117
  | W0117 | 3 | 6 |
114
118
  | W1049 | 5 | 9 |
119
+ | C1000 | | |
120
+ | C1006 | 3 | 20 |
115
121
  | W0104 | 3 | 20 |
116
122
  | W0834 | 3 | 10 |
117
123
  | W0628 | 3 | 6 |
@@ -147,6 +153,8 @@ Feature: W0761
147
153
  | mesg | line | column |
148
154
  | W0117 | 1 | 5 |
149
155
  | W1049 | 3 | 12 |
156
+ | C1000 | | |
157
+ | C1006 | 1 | 19 |
150
158
  | W0104 | 1 | 19 |
151
159
  | W0834 | 1 | 9 |
152
160
  | W0628 | 1 | 5 |
@@ -33,6 +33,8 @@ Feature: W0762
33
33
  | mesg | line | column |
34
34
  | W0117 | 1 | 6 |
35
35
  | W1049 | 3 | 14 |
36
+ | C1000 | | |
37
+ | C1006 | 1 | 20 |
36
38
  | W0100 | 3 | 10 |
37
39
  | W0104 | 1 | 20 |
38
40
  | W0834 | 1 | 10 |
@@ -71,6 +73,8 @@ Feature: W0762
71
73
  | mesg | line | column |
72
74
  | W0117 | 1 | 6 |
73
75
  | W1049 | 4 | 9 |
76
+ | C1000 | | |
77
+ | C1006 | 1 | 20 |
74
78
  | W0100 | 3 | 10 |
75
79
  | W0104 | 1 | 20 |
76
80
  | W0834 | 1 | 10 |
@@ -112,6 +116,8 @@ Feature: W0762
112
116
  | W0118 | 1 | 13 |
113
117
  | W0117 | 3 | 6 |
114
118
  | W1049 | 5 | 9 |
119
+ | C1000 | | |
120
+ | C1006 | 3 | 20 |
115
121
  | W0104 | 3 | 20 |
116
122
  | W0834 | 3 | 10 |
117
123
  | W0628 | 3 | 6 |
@@ -147,6 +153,8 @@ Feature: W0762
147
153
  | mesg | line | column |
148
154
  | W0117 | 1 | 6 |
149
155
  | W1049 | 3 | 12 |
156
+ | C1000 | | |
157
+ | C1006 | 1 | 20 |
150
158
  | W0104 | 1 | 20 |
151
159
  | W0834 | 1 | 10 |
152
160
  | W0628 | 1 | 6 |
@@ -15,6 +15,8 @@ Feature: W0794
15
15
  | mesg | line | column |
16
16
  | W0117 | 1 | 5 |
17
17
  | W0570 | 3 | 14 |
18
+ | C1000 | | |
19
+ | C1006 | 1 | 14 |
18
20
  | W0572 | 3 | 14 |
19
21
  | W0794 | 3 | 14 |
20
22
  | W0104 | 1 | 14 |
@@ -50,6 +52,8 @@ Feature: W0794
50
52
  | mesg | line | column |
51
53
  | W0117 | 1 | 14 |
52
54
  | W0116 | 3 | 15 |
55
+ | C1000 | | |
56
+ | C1006 | 1 | 32 |
53
57
  | W0104 | 1 | 32 |
54
58
  | W0628 | 1 | 14 |
55
59
 
@@ -83,5 +87,7 @@ Feature: W0794
83
87
  | W0117 | 1 | 5 |
84
88
  | W0246 | 3 | 12 |
85
89
  | W0116 | 3 | 15 |
90
+ | C1000 | | |
91
+ | C1006 | 1 | 24 |
86
92
  | W0104 | 1 | 24 |
87
93
  | W0628 | 1 | 5 |
@@ -32,9 +32,17 @@ Feature: W1050
32
32
  | mesg | line | column |
33
33
  | W1076 | 1 | 13 |
34
34
  | W1050 | 4 | 31 |
35
+ | C1000 | | |
36
+ | C1006 | 1 | 27 |
35
37
  | W1050 | 7 | 31 |
38
+ | C1000 | | |
39
+ | C1006 | 1 | 27 |
36
40
  | W1049 | 11 | 31 |
41
+ | C1000 | | |
42
+ | C1006 | 1 | 27 |
37
43
  | W1049 | 14 | 31 |
44
+ | C1000 | | |
45
+ | C1006 | 1 | 27 |
38
46
  | W0629 | 1 | 13 |
39
47
  | W0489 | 17 | 9 |
40
48
  | W0490 | 17 | 9 |
@@ -27,6 +27,8 @@ Feature: W1066
27
27
  | W0723 | 6 | 21 |
28
28
  | W1066 | 6 | 21 |
29
29
  | W0093 | 7 | 21 |
30
+ | C1000 | | |
31
+ | C1006 | 1 | 33 |
30
32
  | W1066 | 7 | 21 |
31
33
  | W0104 | 1 | 24 |
32
34
  | W0104 | 1 | 33 |
@@ -51,7 +53,11 @@ Feature: W1066
51
53
  | mesg | line | column |
52
54
  | W1076 | 1 | 13 |
53
55
  | W0093 | 4 | 21 |
56
+ | C1000 | | |
57
+ | C1006 | 1 | 33 |
54
58
  | W0570 | 6 | 21 |
59
+ | C1000 | | |
60
+ | C1006 | 1 | 24 |
55
61
  | W0572 | 6 | 21 |
56
62
  | W0794 | 6 | 21 |
57
63
  | W0572 | 7 | 21 |
@@ -83,6 +89,8 @@ Feature: W1066
83
89
  | W0723 | 6 | 11 |
84
90
  | W0777 | 6 | 11 |
85
91
  | W0093 | 7 | 11 |
92
+ | C1000 | | |
93
+ | C1006 | 1 | 33 |
86
94
  | W0777 | 7 | 11 |
87
95
  | W0104 | 1 | 24 |
88
96
  | W0104 | 1 | 33 |
@@ -27,6 +27,8 @@ Feature: W1067
27
27
  | W0723 | 6 | 26 |
28
28
  | W1067 | 6 | 26 |
29
29
  | W0093 | 7 | 26 |
30
+ | C1000 | | |
31
+ | C1006 | 1 | 33 |
30
32
  | W1067 | 7 | 26 |
31
33
  | W0104 | 1 | 24 |
32
34
  | W0104 | 1 | 33 |
@@ -51,7 +53,11 @@ Feature: W1067
51
53
  | mesg | line | column |
52
54
  | W1076 | 1 | 13 |
53
55
  | W0093 | 4 | 26 |
56
+ | C1000 | | |
57
+ | C1006 | 1 | 33 |
54
58
  | W0570 | 6 | 26 |
59
+ | C1000 | | |
60
+ | C1006 | 1 | 24 |
55
61
  | W0572 | 6 | 26 |
56
62
  | W0794 | 6 | 26 |
57
63
  | W0572 | 7 | 26 |
@@ -83,6 +89,8 @@ Feature: W1067
83
89
  | W0723 | 6 | 11 |
84
90
  | W0778 | 6 | 11 |
85
91
  | W0093 | 7 | 11 |
92
+ | C1000 | | |
93
+ | C1006 | 1 | 33 |
86
94
  | W0778 | 7 | 11 |
87
95
  | W0104 | 1 | 24 |
88
96
  | W0104 | 1 | 33 |
@@ -27,6 +27,8 @@ Feature: W1068
27
27
  | W0723 | 6 | 26 |
28
28
  | W1068 | 6 | 26 |
29
29
  | W0093 | 7 | 26 |
30
+ | C1000 | | |
31
+ | C1006 | 1 | 35 |
30
32
  | W1068 | 7 | 26 |
31
33
  | W0104 | 1 | 25 |
32
34
  | W0104 | 1 | 35 |
@@ -51,7 +53,11 @@ Feature: W1068
51
53
  | mesg | line | column |
52
54
  | W1076 | 1 | 13 |
53
55
  | W0093 | 4 | 26 |
56
+ | C1000 | | |
57
+ | C1006 | 1 | 35 |
54
58
  | W0570 | 6 | 26 |
59
+ | C1000 | | |
60
+ | C1006 | 1 | 25 |
55
61
  | W0572 | 6 | 26 |
56
62
  | W0794 | 6 | 26 |
57
63
  | W0572 | 7 | 26 |
@@ -83,6 +89,8 @@ Feature: W1068
83
89
  | W0723 | 6 | 11 |
84
90
  | W0779 | 6 | 11 |
85
91
  | W0093 | 7 | 11 |
92
+ | C1000 | | |
93
+ | C1006 | 1 | 35 |
86
94
  | W0779 | 7 | 11 |
87
95
  | W0104 | 1 | 25 |
88
96
  | W0104 | 1 | 35 |
@@ -101,7 +101,11 @@ Feature: W1071
101
101
  | mesg | line | column |
102
102
  | W1076 | 6 | 13 |
103
103
  | W0422 | 9 | 22 |
104
+ | C1000 | | |
105
+ | C1005 | 6 | 29 |
104
106
  | W0422 | 10 | 14 |
107
+ | C1000 | | |
108
+ | C1005 | 6 | 29 |
105
109
  | W0104 | 6 | 29 |
106
110
  | W0105 | 6 | 29 |
107
111
  | W1071 | 6 | 13 |
@@ -285,6 +285,8 @@ Feature: W9003
285
285
  | mesg | line | column |
286
286
  | W1076 | 1 | 13 |
287
287
  | W0459 | 5 | 9 |
288
+ | C1000 | | |
289
+ | C1003 | 3 | 19 |
288
290
  | W0642 | 5 | 9 |
289
291
  | W0100 | 3 | 19 |
290
292
  | W0100 | 4 | 11 |
data/lib/adlint/cc1.rb CHANGED
@@ -52,6 +52,7 @@ require "adlint/cc1/scanner"
52
52
  require "adlint/cc1/scope"
53
53
  require "adlint/cc1/seqp"
54
54
  require "adlint/cc1/syntax"
55
+ require "adlint/cc1/trace"
55
56
  require "adlint/cc1/type"
56
57
  require "adlint/cc1/util"
57
58
  require "adlint/cc1/value"
@@ -42,12 +42,16 @@ module Cc1 #:nodoc:
42
42
  @group = branch_group
43
43
  @options = opts
44
44
  @break_event = nil
45
- @controlling_expression = nil
45
+ @ctrlexpr = nil
46
46
  end
47
47
 
48
48
  attr_reader :group
49
49
  attr_reader :break_event
50
- attr_reader :controlling_expression
50
+ attr_reader :ctrlexpr
51
+
52
+ def trunk
53
+ @group.trunk
54
+ end
51
55
 
52
56
  def add_options(*new_opts)
53
57
  @options = (@options + new_opts).uniq
@@ -86,8 +90,8 @@ module Cc1 #:nodoc:
86
90
  env.enter_versioning_group if first?
87
91
  env.begin_versioning
88
92
 
89
- @controlling_expression = ControllingExpression.new(interp, self, expr)
90
- if ensure_condition(@controlling_expression)
93
+ @ctrlexpr = ControllingExpression.new(interp, self, expr)
94
+ if ensure_condition(@ctrlexpr)
91
95
  @break_event = BreakEvent.catch { yield(self) }
92
96
  else
93
97
  unless final? && @group.branches.size == 1
@@ -96,7 +100,7 @@ module Cc1 #:nodoc:
96
100
  end
97
101
 
98
102
  ensure
99
- if @controlling_expression.complexly_compounded? && !complemental?
103
+ if @ctrlexpr.complexly_compounded? && !complemental?
100
104
  # NOTE: Give up value domain thinning of the controlling variables,
101
105
  # because the controlling expression is too complex to manage
102
106
  # value domains correctly.
@@ -125,13 +129,13 @@ module Cc1 #:nodoc:
125
129
  end
126
130
 
127
131
  def restart_versioning(&block)
128
- @controlling_expression.save_affected_variables
132
+ @ctrlexpr.save_affected_variables
129
133
  env.end_versioning(false)
130
134
  env.leave_versioning_group(true)
131
135
  env.enter_versioning_group
132
136
  env.begin_versioning
133
137
  yield
134
- @controlling_expression.restore_affected_variables
138
+ @ctrlexpr.restore_affected_variables
135
139
  end
136
140
 
137
141
  def break_with_break?
@@ -175,17 +179,30 @@ module Cc1 #:nodoc:
175
179
  include BranchOptions
176
180
  include BranchGroupOptions
177
181
 
178
- def initialize(env, parent, *opts)
182
+ def initialize(env, trunk, *opts)
179
183
  @environment = env
180
- @parent_group = parent
184
+ @trunk = trunk
181
185
  @options = opts
182
186
  @branches = []
183
187
  end
184
188
 
185
189
  attr_reader :environment
186
- attr_reader :parent_group
190
+ attr_reader :trunk
187
191
  attr_reader :branches
188
192
 
193
+ def trunk_group
194
+ @trunk ? @trunk.group : nil
195
+ end
196
+
197
+ def branches_to_trunk(acc = [])
198
+ if @trunk
199
+ acc.push(@trunk)
200
+ @trunk.group.branches_to_trunk(acc)
201
+ else
202
+ acc
203
+ end
204
+ end
205
+
189
206
  def add_options(*new_opts)
190
207
  @options = (@options + new_opts).uniq
191
208
  end
@@ -199,10 +216,10 @@ module Cc1 #:nodoc:
199
216
  end
200
217
 
201
218
  def in_iteration?
202
- branch_group = @parent_group
219
+ branch_group = trunk_group
203
220
  while branch_group
204
221
  return true if branch_group.iteration?
205
- branch_group = branch_group.parent_group
222
+ branch_group = branch_group.trunk_group
206
223
  end
207
224
  false
208
225
  end
@@ -219,7 +236,7 @@ module Cc1 #:nodoc:
219
236
 
220
237
  def all_controlling_variables
221
238
  @branches.map { |br|
222
- ctrlexpr = br.controlling_expression and ctrlexpr.affected_variables
239
+ ctrlexpr = br.ctrlexpr and ctrlexpr.affected_variables
223
240
  }.compact.flatten.uniq
224
241
  end
225
242
 
@@ -238,6 +255,10 @@ module Cc1 #:nodoc:
238
255
  def all_branches_break_with_return?
239
256
  @branches.all? { |br| br.break_with_return? }
240
257
  end
258
+
259
+ def current_branch
260
+ @branches.last
261
+ end
241
262
  end
242
263
 
243
264
  class BreakEvent