~ubuntu-branches/ubuntu/jaunty/adacontrol/jaunty

« back to all changes in this revision

Viewing changes to test/t_simplifiable_expressions.adb

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Brenta
  • Date: 2006-10-12 19:17:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061012191722-fo5bcn4k5r0iubgd
Tags: 1.5r24-1

* New upstream release.
* debian/control (Depends): add gnat-4.1.
  (Enhances): add gnat-gps.
* debian/adacontrol.gpr: build pfni.
* debian/rules: install the new gnat-gps plug-in, and pfni.
* debian/pfni.1: new.
* patches/gps-integration.patch: new.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
      type Array_Type is array  (PST1 range <>) of String (1..10);
35
35
      type Array_Type1 is array (PST1 range <>) of String (PST1'FIRST .. PST1'LAST); -- Should trigger
36
36
      type Array_Type2 is array (PST1 range <>) of String (PST1'RANGE);              -- Should trigger
37
 
      type Array_Type3 is array (PST1 range <>) of String (PST1'FIRST .. PST2'LAST); -- Should not trigger
 
37
      type Array_Type3 is array (PST1 range <>) of String (PST1'FIRST .. PST2'LAST); -- OK
38
38
      type Array_Type4 is new Array_Type3 (1..2);
39
39
 
40
40
      subtype ST1A is Array_Type (PST1'FIRST .. PST1'LAST); -- Should trigger
41
41
      subtype ST2A is Array_Type (PST1'RANGE);              -- Should trigger
42
 
      subtype ST3A is Array_Type (PST1'FIRST .. PST2'LAST); -- Should not trigger
 
42
      subtype ST3A is Array_Type (PST1'FIRST .. PST2'LAST); -- OK
43
43
 
44
44
      SA1 : ST1A;
45
45
      SA2 : ST2A;
62
62
      end Gen;
63
63
 
64
64
   begin
65
 
      for I in Tab'First(1)..Tab'Last(2) loop -- Should not trigger
 
65
      for I in Tab'First(1)..Tab'Last(2) loop -- OK
66
66
         null;
67
67
      end loop;
68
68
 
69
 
      for I in Pack1.T'First..Pack2.T'Last loop -- Should not trigger
 
69
      for I in Pack1.T'First..Pack2.T'Last loop -- OK
70
70
         null;
71
71
      end loop;
72
72
 
80
80
      for X in Pack.T'First .. Pack.T'Last loop -- Should trigger
81
81
         null;
82
82
      end loop;
83
 
      for X in T'Base'First .. T'Last loop -- Should not trigger
84
 
         null;
85
 
      end loop;
86
 
      for X in Btype'FIRST .. Btype (Ctype'LAST) loop -- Should not trigger
87
 
         null;
88
 
      end loop;
89
 
      for X in Btype (CType'FIRST) .. Btype'LAST loop -- Should not trigger
90
 
         null;
91
 
      end loop;
92
 
      for X in Btype'FIRST .. Btype'LAST-1 loop -- Should not trigger
93
 
         null;
94
 
      end loop;
95
 
      for X in Btype'FIRST-1 .. Btype'LAST loop -- Should not trigger
96
 
         null;
97
 
      end loop;
98
 
      for X in Btype'LAST .. Btype'FIRST loop -- Should not trigger
 
83
      for X in T'Base'First .. T'Last loop -- OK
 
84
         null;
 
85
      end loop;
 
86
      for X in Btype'FIRST .. Btype (Ctype'LAST) loop -- OK
 
87
         null;
 
88
      end loop;
 
89
      for X in Btype (CType'FIRST) .. Btype'LAST loop -- OK
 
90
         null;
 
91
      end loop;
 
92
      for X in Btype'FIRST .. Btype'LAST-1 loop -- OK
 
93
         null;
 
94
      end loop;
 
95
      for X in Btype'FIRST-1 .. Btype'LAST loop -- OK
 
96
         null;
 
97
      end loop;
 
98
      for X in Btype'LAST .. Btype'FIRST loop -- OK
99
99
         null;
100
100
      end loop;
101
101
      for X in Btype'FIRST .. Btype'LAST loop -- Should trigger
104
104
      for X in Btype'RANGE loop -- Should trigger
105
105
         null;
106
106
      end loop;
107
 
      for X in Btype loop -- Should not trigger
 
107
      for X in Btype loop -- OK
108
108
         null;
109
109
      end loop;
110
110
      for X in Atype'FIRST .. Atype'LAST loop -- Should trigger
112
112
      end loop;
113
113
 
114
114
      for X in ASA'FIRST .. ASA'LAST loop         -- Should trigger
115
 
         ASA(X)(ASA(X)'RANGE) := (others => ' '); -- Should not trigger
 
115
         ASA(X)(ASA(X)'RANGE) := (others => ' '); -- OK
116
116
      end loop;
117
 
      for X in ASA'RANGE loop                                      -- Should not trigger
 
117
      for X in ASA'RANGE loop                                      -- OK
118
118
         ASA(X)(ASA(X)'FIRST .. ASA(X)'LAST) := (others => ' ');   -- Should trigger
119
 
         ASA(X)(ASA(X)'FIRST .. ASA(Ix1)'LAST) := (others => ' '); -- Should not trigger
120
 
         ASA(X)(ASA(X)'FIRST .. A_Var) := (others => ' ');         -- Should not trigger
121
 
         ASA(X)(A_Var .. ASA(X)'LAST) := (others => ' ');          -- Should not trigger
 
119
         ASA(X)(ASA(X)'FIRST .. ASA(Ix1)'LAST) := (others => ' '); -- OK
 
120
         ASA(X)(ASA(X)'FIRST .. A_Var) := (others => ' ');         -- OK
 
121
         ASA(X)(A_Var .. ASA(X)'LAST) := (others => ' ');          -- OK
122
122
      end loop;
123
123
      ASA (ASA'FIRST (1) .. ASA'LAST (1)) := (others => (others => ' ')); -- Should trigger
124
 
      ASA (ASA'RANGE (1)) := (others => (others => ' '));                 -- Should not trigger
 
124
      ASA (ASA'RANGE (1)) := (others => (others => ' '));                 -- OK
125
125
      ASA(1)(ASA(Ix1)'FIRST .. ASA(Ix1)'LAST) := (others => ' ');         -- Should trigger
126
 
      ASA(1)(ASA(Ix1)'FIRST .. ASA(Ix2)'LAST) := (others => ' ');         -- Should not trigger
 
126
      ASA(1)(ASA(Ix1)'FIRST .. ASA(Ix2)'LAST) := (others => ' ');         -- OK
127
127
 
128
128
      SA1 (ST1A'FIRST .. ST1A'LAST) := (others => (others => ' ')); -- Should trigger
129
 
      SA1 (ST1A'FIRST .. ST2A'LAST) := (others => (others => ' ')); -- Should not trigger
 
129
      SA1 (ST1A'FIRST .. ST2A'LAST) := (others => (others => ' ')); -- OK
130
130
      SA2 (ST1A'FIRST .. ST1A'LAST) := (others => (others => ' ')); -- Should trigger
131
131
 
132
 
      ASA (PST1) := (others => (others => ' '));                    -- Should not trigger
 
132
      ASA (PST1) := (others => (others => ' '));                    -- OK
133
133
      ASA (PST1'FIRST .. PST1'LAST) := (others => (others => ' ')); -- Should trigger
134
134
      ASA (PST2'FIRST .. PST2'LAST) := (others => (others => ' ')); -- Should trigger
135
 
      ASA (PST1'FIRST .. PST2'LAST) := (others => (others => ' ')); -- Should not trigger
 
135
      ASA (PST1'FIRST .. PST2'LAST) := (others => (others => ' ')); -- OK
136
136
 
137
 
      ASB (PST1) := (others => (others => ' '));                              -- Should not trigger
 
137
      ASB (PST1) := (others => (others => ' '));                              -- OK
138
138
      ASB (PST1'BASE'FIRST .. PST1'BASE'LAST) := (others => (others => ' ')); -- Should trigger
139
 
      ASB (PST1'BASE'FIRST .. PST1'LAST) := (others => (others => ' '));      -- Should not trigger
140
 
      ASB (PST1'FIRST .. PST2'LAST) := (others => (others => ' '));           -- Should not trigger
 
139
      ASB (PST1'BASE'FIRST .. PST1'LAST) := (others => (others => ' '));      -- OK
 
140
      ASB (PST1'FIRST .. PST2'LAST) := (others => (others => ' '));           -- OK
141
141
      ASB (ASB'FIRST .. ASB'LAST) := (others => (others => ' '));             -- Should trigger
142
142
 
143
143
      for I in Renaming'First..Renaming'Last loop  -- Should trigger
144
144
         null;
145
145
      end loop;
146
146
 
147
 
      for I in Renaming'Range loop -- Should not trigger
 
147
      for I in Renaming'Range loop -- OK
148
148
         null;
149
149
      end loop;
150
150
 
151
 
      for I in Array_Type4'range loop  -- Should not trigger
 
151
      for I in Array_Type4'range loop  -- OK
152
152
         null;
153
153
      end loop;
154
154
   end Test_Range;
161
161
         return True;
162
162
      end Y;
163
163
 
164
 
      A : Boolean := Y = False;
165
 
      B : constant Boolean := Y = False;
 
164
      A : Boolean := Y = False;               -- Should trigger
 
165
      B : constant Boolean := Y = False;      -- Should trigger
166
166
 
167
 
      procedure Z (P : in Boolean := Y = False) is
 
167
      procedure Z (P : in Boolean := Y = False) is -- Should trigger
168
168
      begin
169
169
         A := B;
170
170
      end Z;
171
171
 
172
172
   begin
173
173
 
174
 
      if X = False and then Y = True then
 
174
      if X = False and then Y = True then    -- Should trigger (twice)
175
175
         Z;
176
 
      elsif X = False then
177
 
         X := Y = False;
178
 
      elsif X /= False then
179
 
         null;
180
 
      elsif X = True then
181
 
         null;
182
 
      elsif X /= True then
183
 
         null;
184
 
      elsif False = X then
185
 
         X := Y = False;
186
 
      elsif False /= X then
187
 
         null;
188
 
      elsif True = X then
189
 
         null;
190
 
      elsif True /= X then
 
176
      elsif X = False then                   -- Should trigger
 
177
         X := Y = False;                     -- Should trigger
 
178
      elsif X /= False then                  -- Should trigger
 
179
         null;
 
180
      elsif X = True then                    -- Should trigger
 
181
         null;
 
182
      elsif X /= True then                   -- Should trigger
 
183
         null;
 
184
      elsif False = X then                   -- Should trigger
 
185
         X := Y = False;
 
186
      elsif False /= X then                  -- Should trigger
 
187
         null;
 
188
      elsif True = X then                    -- Should trigger
 
189
         null;
 
190
      elsif True /= X then                   -- Should trigger
191
191
         null;
192
192
      end if;
193
193
 
194
 
      while Y = False and X = False loop
 
194
      while Y = False and X = False loop     -- Should trigger (twice)
195
195
         A := B;
196
196
      end loop;
197
197
   end Test_Logical;
198
198
 
199
199
   procedure Test_Parentheses is
 
200
      I : Integer := 1;   -- OK
 
201
      J : Integer := (1); -- Should Trigger
200
202
      B : Boolean;
 
203
      procedure P (X : Integer) is
 
204
      begin
 
205
         null;
 
206
      end P;
201
207
   begin
202
 
      if (B) then
203
 
         null;
204
 
      elsif (B) then
205
 
         null;
206
 
      end if;
207
 
 
208
 
      case (B) is
209
 
         when others =>
210
 
            null;
211
 
      end case;
212
 
      if B then
213
 
         null;
214
 
      elsif B then
215
 
         null;
216
 
      end if;
217
 
 
218
 
      case B is
219
 
         when others =>
220
 
            null;
221
 
      end case;
 
208
      -- Statements
 
209
 
 
210
      I := (1); -- Should Trigger
 
211
      I := 1;   -- OK
 
212
 
 
213
      if (B) then     -- Should Trigger
 
214
         null;
 
215
      elsif (B) then  -- Should Trigger
 
216
         null;
 
217
      end if;
 
218
      if B then       -- OK
 
219
         null;
 
220
      elsif B then    -- OK
 
221
         null;
 
222
      end if;
 
223
 
 
224
      case (B) is     -- Should Trigger
 
225
         when others =>
 
226
            null;
 
227
      end case;
 
228
      case B is       -- OK
 
229
         when others =>
 
230
            null;
 
231
      end case;
 
232
 
 
233
      P ((1)); -- Should Trigger
 
234
      P (1);   -- OK
 
235
 
 
236
      -- Arithmetic
 
237
      I := 1 + (2*3);       -- Should Trigger
 
238
      I := (1) + 2*3;       -- Should Trigger
 
239
      I := 1 * (2+3);       -- OK
 
240
      I := 1 * ("+"(2, 3)); -- Should Trigger
 
241
      I := "*"(1, (2+3));   -- Should Trigger
 
242
      I := 3 + abs (I);     -- Should Trigger
 
243
      I := 3 + (abs I);     -- Should Trigger
 
244
      I := I ** (3);        -- Should Trigger
 
245
      I := I ** (3+1);      -- OK
 
246
      I := (I+1) ** 3;      -- OK
 
247
 
 
248
      -- Simple logical
 
249
      B := I = 1 or (I = 2 or  I = 3);  -- OK (removing parentheses changes associativity)
 
250
      B := I = 1 or (I = 2 and I = 3);  -- OK
 
251
      B := not (B);                     -- Should Trigger
 
252
      B := not (B and B);               -- OK
 
253
      B := (not B) and B;               -- Should Trigger
 
254
 
 
255
      -- Short circuits
 
256
      B := I = 1 or (I = 2 and then I = 3);        -- OK
 
257
      B := I = 1 or else (I = 2 and then I = 3);   -- OK
 
258
      B := I = 1 and then (I = 2 and then I = 3);  -- Should Trigger
 
259
      B := I = 1 and then (I = 2);                 -- Should Trigger
 
260
      B := I = 1 and then (B or B);                -- OK
 
261
      B := (I = 1) and then B;                     -- Should Trigger
 
262
      B := I = 1 and then (B);                     -- Should Trigger
 
263
      B := I = 1 and then ("or" (B, B));           -- Should Trigger
222
264
   end Test_Parentheses;
223
265
begin
224
266
   Test_Range;