You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: flattening/modelica/scodeinst/ClassExtends2.mo
+11-6Lines changed: 11 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,10 @@
1
-
// name: classextends1.mo
1
+
// name: ClassExtends2.mo
2
2
// keywords:
3
3
// status: correct
4
-
// cflags: -d=newInst
4
+
// cflags: -d=newInst
5
+
//
6
+
// Checks that class extends without redeclare works, although with a warning
7
+
// since it was deprecated in Modelica 3.4.
5
8
//
6
9
7
10
model A
@@ -17,7 +20,7 @@ model A
17
20
M2 m2_a;
18
21
end A;
19
22
20
-
modelB
23
+
modelClassExtends2
21
24
extends A;
22
25
23
26
model extends M1
@@ -30,10 +33,10 @@ model B
30
33
31
34
M1 m1_b;
32
35
M2 m2_b;
33
-
endB;
36
+
endClassExtends2;
34
37
35
38
// Result:
36
-
// class B
39
+
// class ClassExtends2
37
40
// Real m1_a.x;
38
41
// Real m1_a.y;
39
42
// Real m2_a.x;
@@ -42,5 +45,7 @@ end B;
42
45
// Real m1_b.y;
43
46
// Real m2_b.x;
44
47
// Real m2_b.y;
45
-
// end B;
48
+
// end ClassExtends2;
49
+
// [flattening/modelica/scodeinst/ClassExtends2.mo:26:3-28:9:writable] Warning: Missing redeclare prefix on class extends M1, treating like redeclare anyway.
Copy file name to clipboardExpand all lines: flattening/modelica/scodeinst/ClassExtends3.mo
+10-6Lines changed: 10 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
-
// name: classextends2.mo
1
+
// name: ClassExtends3
2
2
// keywords:
3
3
// status: correct
4
-
// cflags: -d=newInst
4
+
// cflags: -d=newInst
5
+
//
6
+
// Checks that modifiers on class extends are applied.
5
7
//
6
8
7
9
model A
@@ -17,7 +19,7 @@ model A
17
19
M2 m2_a;
18
20
end A;
19
21
20
-
modelB
22
+
modelClassExtends3
21
23
extends A;
22
24
23
25
model extends M1(x =2.0)
@@ -30,10 +32,10 @@ model B
30
32
31
33
M1 m1_b;
32
34
M2 m2_b;
33
-
endB;
35
+
endClassExtends3;
34
36
35
37
// Result:
36
-
// class B
38
+
// class ClassExtends3
37
39
// Real m1_a.x = 2.0;
38
40
// Real m1_a.y;
39
41
// Real m2_a.x = 3.0;
@@ -42,5 +44,7 @@ end B;
42
44
// Real m1_b.y;
43
45
// Real m2_b.x = 3.0;
44
46
// Real m2_b.y;
45
-
// end B;
47
+
// end ClassExtends3;
48
+
// [flattening/modelica/scodeinst/ClassExtends3.mo:25:3-27:9:writable] Warning: Missing redeclare prefix on class extends M1, treating like redeclare anyway.
// [flattening/modelica/scodeinst/ClassExtendsBuiltin1.mo:17:5-17:17:writable] Error: A class extending from builtin type Real may not have other elements.
27
+
//
28
+
// # Error encountered! Exiting...
29
+
// # Please check the error message and the flags.
// [flattening/modelica/scodeinst/ClassExtendsBuiltin2.mo:14:13-16:13:writable] Error: A class extending from builtin type MyReal may not have other elements.
24
+
//
25
+
// # Error encountered! Exiting...
26
+
// # Please check the error message and the flags.
// Checks that a proper error message is given when no inherited element is found for a class extends.
7
+
//
8
+
9
+
model ClassExtendsMissing1
10
+
redeclaremodel extends B
11
+
Real y =2.0;
12
+
end B;
13
+
14
+
B b;
15
+
end ClassExtendsMissing1;
16
+
17
+
// Result:
18
+
// Error processing file: ClassExtendsMissing1.mo
19
+
// [flattening/modelica/scodeinst/ClassExtendsMissing1.mo:10:13-12:8:writable] Error: Base class targeted by class extends B not found in the inherited classes.
20
+
//
21
+
// # Error encountered! Exiting...
22
+
// # Please check the error message and the flags.
0 commit comments