Parser.hpp: Fix a segmentation fault happening when parseTree is empty
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
94e71ef61e
commit
23f24e55b1
|
@ -149,19 +149,21 @@ namespace Parser {
|
||||||
} catch (const NamedIdentifier<true>::identifier_reserved_exception&) {
|
} catch (const NamedIdentifier<true>::identifier_reserved_exception&) {
|
||||||
parsingError(current, " is a reserved identifier", true);
|
parsingError(current, " is a reserved identifier", true);
|
||||||
}
|
}
|
||||||
const auto& last = parseTree.cend() - 1;
|
if (not parseTree.empty()) {
|
||||||
const type_info& lastId = last->get()->getId();
|
const auto& last = parseTree.cend() - 1;
|
||||||
const auto* last_identifier = dynamic_cast<NamedIdentifier<true>*>(last->get());
|
const type_info& lastId = last->get()->getId();
|
||||||
if (last_identifier != nullptr) {
|
const auto* last_identifier = dynamic_cast<NamedIdentifier<true>*>(last->get());
|
||||||
if (lastId != typeid(Define) and
|
if (last_identifier != nullptr) {
|
||||||
any_of(parseTree.cbegin(), last, [&last_identifier](const component_ptr& pointer){
|
if (lastId != typeid(Define) and
|
||||||
try {
|
any_of(parseTree.cbegin(), last, [&last_identifier](const component_ptr& pointer){
|
||||||
return dynamic_cast<NamedIdentifier<true>&>(*pointer).name == last_identifier->name;
|
try {
|
||||||
} catch (const bad_cast&) {
|
return dynamic_cast<NamedIdentifier<true>&>(*pointer).name == last_identifier->name;
|
||||||
return false;
|
} catch (const bad_cast&) {
|
||||||
}
|
return false;
|
||||||
}))
|
}
|
||||||
{ parsingError(current, " has already been defined previously", true); }
|
}))
|
||||||
|
{ parsingError(current, " has already been defined previously", true); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return parseTree;
|
return parseTree;
|
||||||
|
|
Loading…
Reference in New Issue