oop_SE.ttcn 34.7 KB
Newer Older
1
/******************************************************************************
Adam Knapp's avatar
Adam Knapp committed
2
 * Copyright (c) 2000-2021 Ericsson Telecom AB
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Baranyi, Botond
 *
 ******************************************************************************/

module oop_SE { //^In TTCN-3 module//

type component Comp {
  var integer cv_comp;
  const integer cc_comp := -1;
18
  timer c_timer;
19
20
21
22
23
24
25
26
27
28
29
30
31
32
}

type port Port message {
  inout integer
}
with {
  extension "internal"
}

type record Rec {
  integer num,
  charstring str
}

33
34
35
36
37
38
39
40
41
42
43
44
45
type record of integer RoI;

type union Uni {
  integer i,
  float f
}

signature Sig(inout integer p);

type integer SmallNumber (-100..100);

type enumerated Enum { E1, E2, E3 };

46
47
const integer c := 3;

48
49
template integer t := 4;

50
51
52
53
54
55
56
57
58
type class C0 { }

type class C1 extends Nonexistent { } //^In type definition// //^In superclass definition// //There is no local or imported definition with name `Nonexistent'//

type class C2 extends c { } //^In type definition// //^In superclass definition// //`c' is not a reference to a type//

type class C3 extends Rec { } //^In type definition// //^In superclass definition// //Class type expected instead of `@oop_SE.Rec'//


59
type class C4 { //^In type definition//
60
61
  private var integer m_private_inherited;
  /*protected*/ var charstring m_protected_inherited;
62
  public var Rec m_public_inherited; //Class members cannot be public//
63
64
65
66
67
68
69
70
  private function f_private_inherited() {}
  /*protected*/ function f_protected_inherited() {}
  public function f_public_inherited() {}
}

type class C5 extends C4 { //^In type definition//
  private var boolean m_private_own;
  /*protected*/ var float m_protected_own;
71
  public var octetstring m_public_own; //Class members cannot be public//
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
  private function f_private_own() {}
  /*protected*/ function f_protected_own() {}
  public function f_public_own() {}
  
  public function f_member_access_inside() { //^In function definition//
    log(m_private_inherited); //^In log statement// //The member definition `m_private_inherited' in class type `C5' is not visible in this scope//
    log(m_protected_inherited);
    log(m_public_inherited);
    log(m_private_own);
    log(m_protected_own);
    log(m_public_own);
    log(m_nonexistent); //^In log statement// //There is no local or imported definition with name `m_nonexistent'//
    f_private_inherited(); //^In function or altstep instance// //The method definition `f_private_inherited' in class type `C5' is not visible in this scope//
    f_protected_inherited();
    f_public_inherited();
    f_private_own();
    f_protected_own();
    f_public_own();
    f_nonexistent(); //^In function or altstep instance// //There is no local or imported definition with name `f_nonexistent'//
  }
}

function f_member_access_outside() { //^In function definition//
  var C5 obj := C5.create(1, "a", { 2, "b" }, true, 0.1, '12'O);
  log(obj.m_private_inherited); //^In log statement// //The member definition `m_private_inherited' in class type `C5' is not visible in this scope//
  log(obj.m_protected_inherited); //^In log statement// //The member definition `m_protected_inherited' in class type `C5' is not visible in this scope//
  log(obj.m_public_inherited);
  log(obj.m_private_own); //^In log statement// //The member definition `m_private_own' in class type `C5' is not visible in this scope//
  log(obj.m_protected_own); //^In log statement// //The member definition `m_protected_own' in class type `C5' is not visible in this scope//
  log(obj.m_public_own);
  log(obj.m_nonexistent); //^In log statement// //Reference to non-existent member `m_nonexistent' in class type `@oop_SE.C5'//
  obj.f_private_inherited(); //^In function instance// //The method definition `f_private_inherited' in class type `C5' is not visible in this scope//
  obj.f_protected_inherited(); //^In function instance// //The method definition `f_protected_inherited' in class type `C5' is not visible in this scope//
  obj.f_public_inherited();
  obj.f_private_own(); //^In function instance// //The method definition `f_private_own' in class type `C5' is not visible in this scope//
  obj.f_protected_own(); //^In function instance// //The method definition `f_protected_own' in class type `C5' is not visible in this scope//
  obj.f_public_own();
  obj.f_nonexistent(); //^In function instance// //Reference to non-existent method `f_nonexistent' in class type `@oop_SE.C5'//
}

type class C6 { //^In type definition//
  public function f_member_access_other_class() { //^In function definition//
    var C5 obj := C5.create(1, "a", { 2, "b" }, true, 0.1, '12'O);
    log(obj.m_private_inherited); //^In log statement// //The member definition `m_private_inherited' in class type `C5' is not visible in this scope//
    log(obj.m_protected_inherited); //^In log statement// //The member definition `m_protected_inherited' in class type `C5' is not visible in this scope//
    log(obj.m_public_inherited);
    log(obj.m_private_own); //^In log statement// //The member definition `m_private_own' in class type `C5' is not visible in this scope//
    log(obj.m_protected_own); //^In log statement// //The member definition `m_protected_own' in class type `C5' is not visible in this scope//
    log(obj.m_public_own);
    log(obj.m_nonexistent); //^In log statement// //Reference to non-existent member `m_nonexistent' in class type `@oop_SE.C5'//
    obj.f_private_inherited(); //^In function instance// //The method definition `f_private_inherited' in class type `C5' is not visible in this scope//
    obj.f_protected_inherited(); //^In function instance// //The method definition `f_protected_inherited' in class type `C5' is not visible in this scope//
    obj.f_public_inherited();
    obj.f_private_own(); //^In function instance// //The method definition `f_private_own' in class type `C5' is not visible in this scope//
    obj.f_protected_own(); //^In function instance// //The method definition `f_protected_own' in class type `C5' is not visible in this scope//
    obj.f_public_own();
    obj.f_nonexistent(); //^In function instance// //Reference to non-existent method `f_nonexistent' in class type `@oop_SE.C5'//
  }
}


133
type class C7 extends C9 { } //^In type definition// //^In superclass definition//
134

135
type class C8 extends C7 { } //^In type definition// //While checking embedded recursions\: Circular reference\: `@oop_SE.C8' -> `@oop_SE.C8.<superclass>' -> `@oop_SE.C7' -> `@oop_SE.C7.<superclass>' -> `@oop_SE.C9' -> `@oop_SE.C9.<superclass>' -> `@oop_SE.C8'//
136

137
type class C9 extends C8 { } //^In type definition// //^In superclass definition//
138

139
140
141
142
143
144
external const C0 ec_c0; //^In external constant definition// //External constant cannot be defined for class type `@oop_SE.C0'//
external const object ec_obj; //^In external constant definition// //External constant cannot be defined for class type `object'//
modulepar C0 mp_c0; //^In module parameter definition// //Type of module parameter cannot be or embed class type `@oop_SE.C0'//
modulepar object mp_obj; //^In module parameter definition// //Type of module parameter cannot be or embed class type `object'//
modulepar template C0 mpt_c0; //^In template module parameter definition// //Type of template module parameter cannot be class type `@oop_SE.C0'//
modulepar template object mpt_obj; //^In template module parameter definition// //Type of template module parameter cannot be class type `object'//
145
146

function f_defs() { //^In function definition//
147
148
149
150
151
152
153
154
  const C0 c_c0 := null; //^In constant definition// //Constant cannot be defined for class type `@oop_SE.C0'//
  const object c_obj := null; //^In constant definition// //Constant cannot be defined for class type `object'//
  var C0 v_c0;
  var object v_obj;
  template C0 t_c0 := *; //^In template definition// //Template cannot be defined for class type `@oop_SE.C0'//
  template object t_obj := *; //^In template definition// //Template cannot be defined for class type `object'//
  var template C0 vt_c0; //^In template variable definition// //Template variable cannot be defined for class type `@oop_SE.C0'//
  var template object vt_obj; //^In template variable definition// //Template variable cannot be defined for class type `object'//
155
156
157
158
}


type record RecClass { //^In type definition//
159
160
  C0 x, //^In record field// //Class type `@oop_SE.C0' cannot be embedded into another type//
  object y //^In record field// //Class type `object' cannot be embedded into another type//
161
162
163
}

type set SetClass { //^In type definition//
164
165
  C0 x, //^In set field// //Class type `@oop_SE.C0' cannot be embedded into another type//
  object y //^In set field// //Class type `object' cannot be embedded into another type//
166
167
168
}

type record of C0 RecOfClass; //^In type definition// //^In embedded type of record of// //Class type `@oop_SE.C0' cannot be embedded into another type//
169
type record of object RecOfObject; //^In type definition// //^In embedded type of record of// //Class type `object' cannot be embedded into another type//
170
171

type set of C0 SetOfClass; //^In type definition// //^In embedded type of set of// //Class type `@oop_SE.C0' cannot be embedded into another type//
172
type set of object SetOfObject; //^In type definition// //^In embedded type of set of// //Class type `object' cannot be embedded into another type//
173
174

type union UniClass { //^In type definition//
175
176
  C0 x, //^In union field// //Class type `@oop_SE.C0' cannot be embedded into another type//
  object y //^In union field// //Class type `object' cannot be embedded into another type//
177
178
179
180
181
182
183
184
185
}

function f_embedded_types() { //^In function definition//
  var RecClass v_rec := { x := C0.create };
  var SetClass v_set := { x := C0.create };
  var RecOfClass v_recof := { C0.create };
  var SetOfClass v_setof := { C0.create };
  var UniClass v_uni := { x := C0.create };
  var anytype v_any; //^In variable definition// //^In type definition//
Botond Baranyi's avatar
Botond Baranyi committed
186
  v_any.C0 := C0.create;
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
}


function f_type_compatibility() { //^In function definition//
  var C4 x1 := C4.create(1, "a", { 2, "b" });
  var C5 y1 := C4.create(1, "a", { 2, "b" }); //^In variable definition// //Incompatible class types: operation `create' should refer to `@oop_SE.C5' instead of `@oop_SE.C4'//
  var C4 x2 := C5.create(1, "a", { 2, "b" }, true, 0.1, '12'O);
  var C5 y2 := C5.create(1, "a", { 2, "b" }, true, 0.1, '12'O);
  var C4 x3 := y1;
  var C5 y3 := x1; //^In variable definition// //Type mismatch: a value of type `@oop_SE.C5' was expected instead of `@oop_SE.C4'//
  x3 := y2;
  y3 := x2; //^In variable assignment// //Type mismatch: a value of type `@oop_SE.C5' was expected instead of `@oop_SE.C4'//
  log(x1.m_public_inherited);
  log(y1.m_public_inherited);
  log(x1.m_public_own); //^In log statement// //Reference to non-existent member `m_public_own' in class type `@oop_SE.C4'//
  log(y1.m_public_own);
  x1.f_public_inherited();
  y1.f_public_inherited();
  x1.f_public_own(); //^In function instance// //Reference to non-existent method `f_public_own' in class type `@oop_SE.C4'//
  y1.f_public_own();
}


type component CT_RunsOn {
  var integer cv_runs_on;
  const integer cc_runs_on := 0;
}

type component CT_Mtc {
  var integer cv_mtc;
  const integer cc_mtc := 1;
218
  port Port pt;
219
220
221
222
223
}

type component CT_System {
  var integer cv_system;
  const integer cc_system := 2;
224
225
226
227
228
229
230
231
232
233
234
235
236
  port Port pt;
}

type component CT_RunsOn2 extends CT_RunsOn {
  var template integer cvt_runs_on := *;
}

type component CT_Mtc2 extends CT_Mtc {
  var template integer cvt_mtc := ?;
}

type component CT_System2 extends CT_System {
  var template integer cvt_system := omit;
237
238
239
240
241
242
243
244
245
246
247
248
249
250
}

type class C10 runs on CT_RunsOn mtc CT_Mtc system CT_System { //^In type definition//
  public function f_comp_visibility(in integer p1 := cc_runs_on, //^In function definition// //^In formal parameter list//
                                    in integer p2 := cc_mtc,
                                    in integer p3 := cc_system,
                                    in integer p4 := cc_comp) { //^In parameter// //^In default value// //There is no local or imported definition with name `cc_comp'//
    log(cv_runs_on);
    log(cv_mtc);
    log(cv_system);
    log(cv_comp); //^In log statement// //There is no local or imported definition with name `cv_comp'//
  }
}

251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
type class C11 extends C10 { //^In type definition//
  public function f_inherited_comp_visibility(in integer p1 := cc_runs_on, //^In function definition// //^In formal parameter list//
                                              in integer p2 := cc_mtc,
                                              in integer p3 := cc_system,
                                              in integer p4 := cc_comp) { //^In parameter// //^In default value// //There is no local or imported definition with name `cc_comp'//
    log(cv_runs_on);
    log(cv_mtc);
    log(cv_system);
    log(cv_comp); //^In log statement// //There is no local or imported definition with name `cv_comp'//
  }
}

type class C12 extends C10 runs on CT_RunsOn mtc CT_Mtc system CT_System { }

type class C13 extends C11 //^In type definition//
  runs on Comp //^In `runs on' clause// //The `runs on' component type of the subclass, `@oop_SE.Comp', is not compatible with the `runs on' component type of the superclass, `@oop_SE.CT_RunsOn'//
  mtc Comp //^In `mtc' clause// //The `mtc' component type of the subclass, `@oop_SE.Comp', is not compatible with the `mtc' component type of the superclass, `@oop_SE.CT_Mtc'//
  system Comp //^In `system' clause// //The `system' component type of the subclass, `@oop_SE.Comp', is not compatible with the `system' component type of the superclass, `@oop_SE.CT_System'//
  { }

type class C14 extends C11
  runs on CT_RunsOn2
  mtc CT_Mtc2
  system CT_System2
  { }

function f_good_comp_usage() runs on CT_RunsOn mtc CT_Mtc system CT_System {
  var C11 x := C11.create;
}

function f_bad_comp_usage() runs on Comp mtc Comp system Comp { //^In function definition//
  var C11 x := C11.create; //^In variable definition// //Runs on clause mismatch: A definition that runs on component type `@oop_SE.Comp' cannot create a value of class type `@oop_SE.C11', which runs on `@oop_SE.CT_RunsOn'// //Mtc clause mismatch: A definition that runs on component type `@oop_SE.Comp' cannot create a value of class type `@oop_SE.C11', which has `mtc' component type `@oop_SE.CT_Mtc'// //System clause mismatch: A definition that runs on component type `@oop_SE.Comp' cannot create a value of class type `@oop_SE.C11', which has `system' component type `@oop_SE.CT_System'//
}

function f_no_comp_usage() { //^In function definition//
  var C11 x := C11.create; //^In variable definition// //A definition without `runs on' clause cannot create a value of class type `@oop_SE.C11', which runs on component type `@oop_SE.CT_RunsOn'//
}


290
291
292
293
294
295
296
297
298
299
300
301
302
303
type class C15 { //^In type definition//
  var integer v;
  function f() { }
  function g() return boolean { return true; }
  function f_access_with_class_name() { //^In function definition//
    log(C5.v); //^In log statement// //Reference to a value, template, timer, port or class object was expected instead of type `@oop_SE.C5'//
    log(C5.g()); //^In log statement// //Reference to a value, template, timer, port or class object was expected instead of type `@oop_SE.C5'//
    C5.f(); //Reference to a function or altstep was expected instead of type `@oop_SE.C5', which cannot be invoked//
    C5.g(); //Reference to a function or altstep was expected instead of type `@oop_SE.C5', which cannot be invoked//
    if (C5.g()) { log(1); } //^In if statement// //Reference to a value was expected instead of type `@oop_SE.C5'//
    if (C5.v == 1) { log(2); } //^In if statement// //Reference to a value was expected instead of type `@oop_SE.C5'//
    var integer x1 := C5.v + 1; //^In variable definition// //^In the left operand of operation// //Reference to a value was expected instead of type `@oop_SE.C5'//
    var boolean x2 := C5.g(); //^In variable definition// //Reference to a value was expected instead of type `@oop_SE.C5'//
  }
304
305
}

306

307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340


function f_init_values() { //^In function definition//
  var integer v_int := 3;
  var template integer vt_int := (1..10);
  var C4 v1 := 1; //^In variable definition// //class value was expected//
  var C4 v2 := v_int; //^In variable definition// //Type mismatch\: a value of type `@oop_SE.C4' was expected instead of `integer'//
  var C4 v3 := valueof(vt_int) + v_int; //^In variable definition// //Incompatible value\: `@oop_SE.C4' value was expected//
  var C4 v4 := CT_RunsOn.create; //^In variable definition// //Incompatible value\: `@oop_SE.C4' value was expected//
  var C4 v5 := C11.create; //^In variable definition// //Incompatible class types\: operation `create' should refer to `@oop_SE.C4' instead of `@oop_SE.C11'//
}


type class C16 extends C15 { //^In type definition//
  create() : C15(1) { } //Previous definition of `create' is here//
  create(in integer p) : C15(p) { } //Duplicate definition with name `create'//
}

type class C17 { //^In type definition//
  create() : C15(1) { } //^In constructor definition// //^In super-constructor call// //Class type `@oop_SE.C17' does not have a superclass//
}

type class C18 extends C15 { //^In type definition//
  create() : C16() { } //^In constructor definition// //^In super-constructor call// //expected call to constructor of class type `@oop_SE.C15', instead of class type `@oop_SE.C16'//
}

type class C19 extends C15 { //^In type definition//
  create() { } //^In constructor definition// //Missing super-constructor call//
}

type class C20 extends C15 { //^In type definition//
  create() : f_embedded_types() { } //^In constructor definition// //^In super-constructor call// //Reference to constructor was expected instead of function//
}

341
342
343
344
345
346
347
function f_create() { //^In function definition//
  var C0 x1 := C0.create alive; //^In variable definition// //Keyword `alive' cannot be used when creating an object of class type//
  var Comp c1 := Comp.create("a", "b", "c"); //^In variable definition// //Operation `create' for a component type cannot have more than 2 parameters//
  var Comp c2 := Comp.create(? length (3)); //^In variable definition// //A specific value without matching symbols was expected for the first parameter of operation `create'//
  var Comp c3 := Comp.create("a", *); //^In variable definition// //A specific value without matching symbols was expected for the second parameter of operation `create'//
}

348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365

type class @final @abstract C21 { } //^In type definition// //Final classes cannot be abstract//

type class @final C22 { }

type class C23 extends C22 { } //^In type definition// //^In superclass definition// //The superclass cannot be final//

type class @abstract C24 { //^In type definition//
  public function @abstract f1(in Nonexistent a); //^In abstract function definition// //^In formal parameter list// //^In parameter// //There is no local or imported definition with name `Nonexistent'//
  public function @abstract f2() return template Nonexistent; //^In abstract function definition// //^In return type// //There is no local or imported definition with name `Nonexistent'//
  public function @abstract f3() return Port; //^In abstract function definition// //^In return type// //Port type `@oop_SE.Port' cannot be the return type of an abstract function//
}

function f_inst_abstract() { //^In function definition//
  var C24 x := C24.create; //^In variable definition// //Cannot create an instance of abstract class type `@oop_SE.C24'//
}

type class @abstract C25 {
366
  public function @abstract f_abs(inout template integer p) return integer;
367
368
369
}

type class @abstract C26 extends C25 {
370
  public function @abstract f_abs2();
371
372
373
374
375
}

type class C27 extends C26 { } //^In type definition// //Missing implementation of abstract method `@oop_SE.C25.f_abs'// //Missing implementation of abstract method `@oop_SE.C26.f_abs2'//

type class C28 extends C25 { //^In type definition//
376
  var integer f_abs; //variable `@oop_SE.C28.f_abs' shadows inherited method `@oop_SE.C25.f_abs'//
377
378
379
}

type class C29 extends C26 { //^In type definition// //Missing implementation of abstract method `@oop_SE.C25.f_abs'//
380
  public function f_abs2() { }
381
382
383
}

type class C30 extends C26 {
384
385
  public function f_abs(inout template integer p) return integer { return 1; }
  public function f_abs2() { }
386
387
388
}

type class C31 extends C25 { //^In type definition//
389
  public function f_abs(in template integer p) { } //The prototype of method `f_abs' is not identical to that of inherited method `@oop_SE.C25.f_abs'//
390
391
392
}

type class C32 extends C25 { //^In type definition//
393
  public function f_abs(inout integer p) { } //The prototype of method `f_abs' is not identical to that of inherited method `@oop_SE.C25.f_abs'//
394
395
396
}

type class C33 extends C25 { //^In type definition//
397
  public function f_abs(inout template integer q) { } //The prototype of method `f_abs' is not identical to that of inherited method `@oop_SE.C25.f_abs'//
398
399
400
}

type class C34 extends C25 { //^In type definition//
401
  public function f_abs(inout template integer p) return boolean { return false; } //The prototype of method `f_abs' is not identical to that of inherited method `@oop_SE.C25.f_abs'//
402
403
}

404
405
406
407
408
409
410
411
type class @abstract C35 {
  public function @abstract f(in object p) return object;
}

type class C36 extends C35 {
  public function f(in object p) return object { return p; }
}

412

413
type class C37 {
414
415
  const integer c := 3;
  template charstring t := "";
416
417
418
419
420
  public function f1() return Rec { return { 2, "a" }; }
  public function f2() return template charstring { return ?; }
  create() {}
}

421
function f_global_left_hand_side() { //^In function definition//
422
423
424
425
  var C37 x := C37.create;
  x.f1() := { 3, "b" }; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C37.f1'//
  x.f1().num := 3; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C37.f1'//
  x.f2() := "x"; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C37.f2'//
426
427
}

428
429
430
431
type class C38 extends C37 { //^In type definition//
  public function f1() return Rec { return { 3, "b" }; }
  public function f2() return template charstring { return omit; }
  function f_class_left_hand_side() { //^In function definition//
432
433
434
    var C37 x := C37.create;
    x.c := 2; //^In variable assignment// //Reference to a variable or template variable was expected instead of constant `@oop_SE.C37.c'//
    x.t := *; //^In variable assignment// //Reference to a variable or template variable was expected instead of template `@oop_SE.C37.t'//
435
436
437
438
439
440
441
442
443
    this := null; //^In variable assignment// //Reference to a variable or template variable was expected instead of type `@oop_SE.C38'//
    this.c := 4; //^In variable assignment// //Reference to a variable or template variable was expected instead of constant `@oop_SE.C37.c'//
    this.t := ?; //^In variable assignment// //Reference to a variable or template variable was expected instead of template `@oop_SE.C37.t'//
    this.f1().str := "x"; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C38.f1'//
    this.f2() := ?; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C38.f2//
    super.f1().str := "x"; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C38.f1'//
    super.f2() := ?; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C38.f2//
  }
}
444

445
446

type class C39 {
447
448
449
450
  public function f_def(in integer p := 3) return integer { return p; }
}

function f_default() { //^In function definition//
451
452
  var C39 x := C39.create;
  var integer ret1 := x.f_def; //^In variable definition// //Invalid reference to method `f_def' in class type `@oop_SE.C39', reference to a member was expected instead//
453
454
455
456
  var integer ret2 := x.f_def();
}


457
type external class C40 {
458
  create(in integer x);
459
  function f1(in integer p) return octetstring;
460
461
462
  external function f2();
}

463
464
type external class C41 extends C40 { //^In type definition//
  create();
465
466
467
468
469
  const charstring c := "a"; //An external class cannot contain a constant//
  template charstring t := "b"; //An external class cannot contain a template//
  var charstring v; //An external class cannot contain a variable//
  var template charstring vt; //An external class cannot contain a template variable//
  timer tmr; //An external class cannot contain a timer//
470
471
472
  function g1() { } //An external class cannot contain a function//
  function g2(in charstring x) return charstring { return x; } //An external class cannot contain a function//
  function g3() return template charstring { return ?; } //An external class cannot contain a function//
473
474
475
476
477
478
479
480
}

type external class @abstract C42 { //^In type definition// //External classes cannot be abstract//
  function @abstract f(); //An external class cannot contain a function//
}

type external class C43 extends C39 { } //^In type definition// //^In superclass definition// //An external class cannot extend an internal class//

481
type class C44 extends C40 { //^In type definition//
482
  external function f();
483
  create(); //^In constructor definition// //Missing super-constructor call// //Missing constructor body//
484
485
}

486
487
488
489
490
491
492
493
494
495
type class C45 { //^In type definition//
  function f(); //^In external function definition// //Missing function body or `external' keyword//
}


type class C46 extends object { }


type class C47 {
  const integer m1 := 3;
496
  public function m2() return boolean { return true; }
497
  function m3(in integer p) return charstring { return int2str(p); }
498
  function @final m4() { }
499
500
501
502
503
504
}

type class C48 extends C47 { //^In type definition//
  var template octetstring m1; //template variable `@oop_SE.C48.m1' shadows inherited member `@oop_SE.C47.m1'//
  var integer m2; //variable `@oop_SE.C48.m2' shadows inherited method `@oop_SE.C47.m2'//
  function m3() return charstring { return "1"; } //The prototype of method `m3' is not identical to that of inherited method `@oop_SE.C47.m3'//
505
506
507
  function m4() { } //Cannot override final method `@oop_SE.C47.m4'//
}

508
509
510
511
512
type class C49 extends C40 {
  function f1(in integer p) return octetstring { return int2oct(p, 2); }
  function f2() { }
}

513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541

function f_of_operator() { //^In function definition//
  var C0 x := C0.create;
  if (x of object) { log(1); }
  if (x of C0) { log(2); }
  if (x of C5) { log(3); } //^In if statement// //Control never reaches this code because the conditional expression evaluates to false//
  if (x of Comp) { log(4); } //^In if statement// //^In the second operand of operation `of'// //Class type was expected//
  if (C0 of C0) { log(5); } //^In if statement// //^In the first operand of operation `of'// //Reference to a variable or value parameter was expected instead of type `@oop_SE.C0'//
}

function f_select_class() { //^In function definition//
  var C0 x := C0.create;
  select class (x) { //^In select class statement//
    case (C0) { log(1); }
    case (C5) { log(2); } //^In select class case statement// //Control never reaches this code because the case will never be chosen//
    case else { log(3); }
    case (Comp) { log(4); } //^In select class case statement// //Control never reaches this code because of previous effective case\(s\)// //Class type was expected//
  }
  var integer y;
  select class (y) { //^In select class statement// //Reference to a class object was expected//
    case (object) { log(5); }
    case else { log(6); }
  }
}

function f_casting() { //^In function definition//
  var C35 x1 := C36.create;
  var C36 x2 := x1 => C36;
  var C0 x3 := x1 => C0; //^In variable definition// //^In the second operand of operation `=>'// //Cannot cast an object of class type `@oop_SE.C35' to class type `@oop_SE.C0'//
542
  var C35 x4 := x2 => (x1);
543
544
545
  var C36 x5 := c => C36; //^In variable definition// //^In the first operand of operation `=>'// //Reference to a variable or value parameter was expected instead of constant `@oop_SE.c'//
  var Rec x6 := x1 => Rec; //^In variable definition// //^In the second operand of operation `=>'// //Class type was expected//
  var integer x7 := x1 => (x6); //^In variable definition// //^In the second operand of operation `=>'// //Class type was expected//
546
547
}

548
549
550
551
552
553
554
function f_parameters(in boolean p1, inout boolean p2, out boolean p3) { }

function f_param_test() { //^In function definition//
  var C47 x := C47.create(1);
  f_parameters(x.m2(), x.m2(), x.m2()); //^In function instance// //^In actual parameter list of function// //^In parameter #2// //^In parameter #3// //Reference to a variable or value parameter was expected for an \`inout\' value parameter instead of function// //Reference to a variable or value parameter was expected for an \`out\' value parameter instead of function//
}

555
556
557
558
559
560
561
562
563
564
565
function f_class_param(in C39 x) runs on Comp { }

function f_start_comp() { //^In function definition//
  var Comp ct := Comp.create alive;
  var C39 x := C39.create;
  ct.start(x.f_def(1)); //^In start test component statement// //A method of a class cannot be started on a parallel test component//
  ct.done;
  ct.start(f_class_param(x)); //^In start test component statement// //Function `@oop_SE.f_class_param' cannot be started on a parallel test component because parameter `x' is of a class type//
  ct.done;
}

566

567
568
569
570
571
572
573
574
575
type C47 C47_alias; //^In type definition// //Subtyping is not allowed for class type//
type C47_alias C47_alias_alias; //^In type definition// //Subtyping is not allowed for class type//

function f_aliases() {
  var C47_alias x1 := C47_alias.create(1);
  var C47_alias_alias x2 := C47_alias_alias.create(2);
}


576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
function f_exception1(in integer p) return integer exception(integer, charstring, Rec, C0) { return p; }
function f_exception2() exception(boolean, verdicttype, integer, SmallNumber, RoI, Uni, anytype, Comp, RoI[-], Rec.num, Uni.i, Enum) { }
external function ef_exception1(in integer p) return integer exception(integer, charstring, Rec, C0);
altstep a_exception1(in integer p) runs on Comp exception(integer, charstring, Rec, C0) {
  [] c_timer.timeout { }
}

function f_exception3() //^In function definition//
  exception (float, //^In exception list//
  default, //Default type cannot be on the exception list of a function//
  bitstring,
  Port, //Port type `@oop_SE.Port' cannot be on the exception list of a function//
  hexstring,
  Sig, //Signature `@oop_SE.Sig' cannot be on the exception list of a function//
  octetstring) { }
external function ef_exception2() //^In external function definition// 
  exception (universal charstring, //^In exception list// //Type `universal charstring' is already given here//
  integer,
  universal charstring); //Duplicate type in exception list//


function f_raise(in integer p, inout template integer p2) runs on CT_Mtc { //^In function definition// //Previous definition with identifier `p' in higher scope unit is here//
  if (p == 0) { raise 3; }
  if (p == 1) { raise Enum: E2; }
  if (p == 2) { raise int2char(p + 1); }
  if (p == 3) { raise omit; } //^In if statement// //^In raise statement// //Cannot determine the type of the raised exception.//
  if (p == 4) { raise null; } //^In if statement// //^In raise statement// //Cannot determine the type of the raised exception.//
  if (p == 5) { raise pattern "ab?c"; } //^In if statement// //^In raise statement// //A specific value without matching symbols or a reference to a value was expected for a raised exception.//
  var default def := null;
  if (p == 6) { raise def; } //^In if statement// //^In raise statement// //Cannot raise an exception of type default//
  if (p == 7) { raise Sig: { p }; } //^In if statement// //^In raise statement// //Cannot raise an exception of type @oop_SE.Sig//
  if (p == 8) { raise pt; } //^In if statement// //^In raise statement// //Reference to a value was expected instead of port `@oop_SE.CT_Mtc.pt'//
  var template charstring vt := ? length (3);
  if (p == 9) { raise vt; } //^In if statement// //^In raise statement// //A specific value without matching symbols or a reference to a value was expected for a raised exception.//
  if (p == 10) { raise c; }
  if (p == 11) { raise t; } //^In if statement// //^In raise statement// //A specific value without matching symbols or a reference to a value was expected for a raised exception.//
  if (p == 12) { raise p2; } //^In if statement// //^In raise statement// //A specific value without matching symbols or a reference to a value was expected for a raised exception.//
}
catch (integer x) { } //Catch block for the same exception type already defined here//
catch (integer y) { } //Duplicate catch block definition for exception type `integer'//
catch (SmallNumber x) { }
catch (RoI[-] x) { }
catch (Rec.num x) { }
catch (charstring p) { } //Definition with identifier `p' is not unique in the scope hierarchy//
catch (default x) { } //^In exception definition// //Exception cannot be defined for the default type//
catch (Sig x) { } //^In exception definition// //Exception cannot be defined for signature `@oop_SE.Sig'//
catch (Port x) { } //^In exception definition// //Exception cannot be defined for port type `@oop_SE.Port'//
catch (octetstring x) { return; }
finally {
  raise 3; //^In raise statement// //Raise statement cannot be used inside a finally block or the destructor of a class.//
}

function f_return1(in integer p) return integer { //^In function definition//
  if (p > 0) {
    return 0;
  }
  else {
    raise 0;
  }
}
catch (integer x) {
  return x;
}
finally {
  return -1; //^In return statement// //Return statement cannot be used inside a finally block or the destructor of a class.//
}

function f_return2(in integer p) return integer { //^In function definition// //The function has return type, but control might leave it without reaching a return statement//
  if (p > 0) {
    return f_return1(p);
  }
  catch (integer x) {
    log(x);
  }
  else {
    raise 0;
  }
}

type class C50 { } //^In type definition//
finally { //^In class destructor//
  return; //^In return statement// //Return statement cannot be used inside a finally block or the destructor of a class.//
}

type class C51 { } //^In type definition//
finally { //^In class destructor//
  raise 1.0; //^In raise statement// //Raise statement cannot be used inside a finally block or the destructor of a class.//
}


666
667
control { //^In control part//
  var C11 x := C11.create; //^In variable definition// //A definition without `runs on' clause cannot create a value of class type `@oop_SE.C11', which runs on component type `@oop_SE.CT_RunsOn'// //Cannot create value of class type `@oop_SE.C11', which has an `mtc' clause, in the control part.// //Cannot create value of class type `@oop_SE.C11', which has a `system' clause, in the control part.//
668
  raise "abc"; //^In raise statement// //Raise statement cannot be used in the control part. It is allowed only in functions, altsteps and testcases.//
669
}
670
671
672

}
with {
673
  extension "anytype C0, object" //^In anytype field// //Class type `@oop_SE.C0' cannot be embedded into another type// //Class type `object' cannot be added to the anytype//
674
}