diff --git a/CMakeLists.txt b/CMakeLists.txt index b2740f7..2373699 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,10 +161,10 @@ if (Threads_FOUND) endif() option(NO_SELF_PACKER "Disables usage of a self-packer") -if (NOT (UPPERCASE_BUILD_TYPE STREQUAL "DEBUG" OR UPPERCASE_BUILD_TYPE STREQUAL "RELWITHDEBINFO" OR NO_SELF_PACKER OR DEFINED EMSCRIPTEN OR MINGW)) +if (NOT (UPPERCASE_BUILD_TYPE STREQUAL "DEBUG" OR UPPERCASE_BUILD_TYPE STREQUAL "RELWITHDEBINFO" OR NO_SELF_PACKER OR DEFINED EMSCRIPTEN)) include(FindSelfPackers) if (SELF_PACKER_FOR_EXECUTABLE MATCHES upx) # UPX version d61edc9 or higher is required when using a cross-compiler to target the musl C library - if (CMAKE_CXX_LINK_NO_PIE_SUPPORTED) + if (CMAKE_CXX_LINK_NO_PIE_SUPPORTED OR MINGW) # MINGW does not support PIE, yet the variable is set to NO. set(SELF_PACKER_FOR_EXECUTABLE_FLAGS ${SELF_PACKER_FOR_EXECUTABLE_FLAGS} --ultra-brute --best) if (USER_DEFINED_PIE AND CMAKE_POSITION_INDEPENDENT_CODE) message(NOTICE "-- Could NOT manually enable PIE (UPX is in use)") diff --git a/src/headers/parsing/Parser.hpp b/src/headers/parsing/Parser.hpp index e953378..5a9f23d 100644 --- a/src/headers/parsing/Parser.hpp +++ b/src/headers/parsing/Parser.hpp @@ -149,20 +149,20 @@ namespace Parser { } catch (const NamedIdentifier::identifier_reserved_exception&) { parsingError(current, " is a reserved identifier", true); } - try { - const auto& last = parseTree.cend() - 1; - const type_info& lastId = last->get()->getId(); - const auto& last_identifier = dynamic_cast&>(**last); + const auto& last = parseTree.cend() - 1; + const type_info& lastId = last->get()->getId(); + const auto& last_identifier = dynamic_cast*>(last->get()); + if (last_identifier != nullptr) { if (lastId != typeid(Define) and any_of(parseTree.cbegin(), last, [&last_identifier](const component_ptr& pointer){ try { - return dynamic_cast&>(*pointer).name == last_identifier.name; + return dynamic_cast&>(*pointer).name == last_identifier->name; } catch (const bad_cast&) { return false; } })) { parsingError(current, " has already been defined previously", true); } - } catch (const bad_cast&) {} + } } return parseTree; }