Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of enumeration(:) (#11056)
- Fix redeclaration of `enumeration(:)` when the redeclaring type is a derived type. - Add check that there are no components with type `enumeration(:)` in the model. Fixes #11053
- Loading branch information
Showing
9 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
testsuite/flattening/modelica/scodeinst/EnumUnspecified1.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// name: EnumUnspecified1 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
model EnumUnspecified1 | ||
replaceable type E = enumeration(:); | ||
E e; | ||
end EnumUnspecified1; | ||
|
||
// Result: | ||
// Error processing file: EnumUnspecified1.mo | ||
// [flattening/modelica/scodeinst/EnumUnspecified1.mo:9:3-9:6:writable] Error: Component 'e' has an unspecified enumeration type (enumeration(:)). | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// name: RedeclareEnum5 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
model A | ||
replaceable type E = enumeration(:); | ||
E e; | ||
end A; | ||
|
||
model RedeclareEnum5 | ||
extends A(redeclare type E = E3); | ||
type E2 = enumeration(a, b, c); | ||
type E3 = E2; | ||
end RedeclareEnum5; | ||
|
||
|
||
// Result: | ||
// class RedeclareEnum5 | ||
// enumeration(a, b, c) e; | ||
// end RedeclareEnum5; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// name: RedeclareEnum6 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
model A | ||
replaceable type E = enumeration(:); | ||
E e; | ||
end A; | ||
|
||
model RedeclareEnum6 | ||
extends A(redeclare type E = E2); | ||
type E2 = Real; | ||
end RedeclareEnum6; | ||
|
||
|
||
// Result: | ||
// Error processing file: RedeclareEnum6.mo | ||
// [flattening/modelica/scodeinst/RedeclareEnum6.mo:13:23-13:34:writable] Notification: From here: | ||
// [flattening/modelica/scodeinst/RedeclareEnum6.mo:8:15-8:38:writable] Error: Redeclaration of enumeration 'E' is not a subtype of the redeclared element. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// endResult |