Schema parser: prohibit declaration of an array of pointers inside structs (#5907)

* Fix issue #5906, Prohibit declaration of an array of pointers inside structs

- idl_parser.cpp: Prohibit declaration of an array of pointers inside structs
- idl_gen_cpp.cpp: Extract GenStructConstructor() method from GenStruct() to simplify future modification
- idl_gen_cpp.cpp: Add assert for checking of Array fields in structs on code-generation stage

* Fix the error 'unused local variable' in release build

* Fix: format the PR code according to coding rules

* Add test-case and fix review notes
This commit is contained in:
Vladimir Glavnyy
2020-05-15 01:39:58 +07:00
committed by GitHub
parent c3faa83463
commit 424a473e1f
3 changed files with 83 additions and 63 deletions

View File

@@ -1623,6 +1623,9 @@ void ErrorTest() {
TestError("table X { Y:int; } root_type X; { Y:1.0 }", "float");
TestError("table X { Y:bool; } root_type X; { Y:1.0 }", "float");
TestError("enum X:bool { Y = true }", "must be integral");
// Array of non-scalar
TestError("table X { x:int; } struct Y { y:[X:2]; }",
"may contain only scalar or struct fields");
}
template<typename T>