| 2413 | } |
| 2414 | |
| 2415 | CheckedError Parser::StartStruct(const std::string &name, StructDef **dest) { |
| 2416 | auto &struct_def = *LookupCreateStruct(name, true, true); |
| 2417 | if (!struct_def.predecl) return Error("datatype already exists: " + name); |
| 2418 | struct_def.predecl = false; |
| 2419 | struct_def.name = name; |
| 2420 | struct_def.file = file_being_parsed_; |
| 2421 | // Move this struct to the back of the vector just in case it was predeclared, |
| 2422 | // to preserve declaration order. |
| 2423 | *std::remove(structs_.vec.begin(), structs_.vec.end(), &struct_def) = |
| 2424 | &struct_def; |
| 2425 | *dest = &struct_def; |
| 2426 | return NoError(); |
| 2427 | } |
| 2428 | |
| 2429 | CheckedError Parser::CheckClash(std::vector<FieldDef *> &fields, |
| 2430 | StructDef *struct_def, const char *suffix, |