diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-11-21 15:19:45 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-11-21 15:19:45 +0100 |
commit | 7edbd99775416a32c88acf8e9379518436905f02 (patch) | |
tree | 6356edb79f846df4aa2f6a8a5ecfeef4e651bcc0 /cpp.cpp | |
parent | 7250bbe5ae2d2ee6b0334bc462aab73f7d8dac0e (diff) |
Support gcc 10 and clang 11
Diffstat (limited to 'cpp.cpp')
-rw-r--r-- | cpp.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -10,9 +10,6 @@ #include "grammer.h" #include "minicc.h" -#include <gtest/gtest.h> -#include <gmock/gmock.h> - #include <boost/core/demangle.hpp> #include <functional> @@ -399,7 +396,7 @@ std::unordered_map<std::string, std::function<std::any(index_t)>> CPP::getNodeEv }, { "multiplicative-expression", [&](index_t index) -> std::any { - if (childTypesOfNodeMatch(index, {"multiplicative-expression", "*", "pm-expression"})) { + if (childTypesOfNodeMatch(index, {"multiplicative-expression", "", "pm-expression"})) { if (getValue(index, 0).type() != typeid(FlowGraph::Graph)) throw std::runtime_error("ICE: multiplicative-expression: Bad data type for argument 1: "s + demangle(getValue(index, 0).type())); if (getValue(index, 2).type() != typeid(FlowGraph::Graph)) @@ -416,7 +413,17 @@ std::unordered_map<std::string, std::function<std::any(index_t)>> CPP::getNodeEv FlowGraph::Data destination{FlowGraph::MakeTemporaryInt(result.scope())}; - std::shared_ptr<FlowGraph::Node> node {std::make_shared<FlowGraph::BinaryOperation>(FlowGraph::BinaryOperationType::Multiply, + FlowGraph::BinaryOperationType type{}; + if (getType(index, 1) == "*") + type = FlowGraph::BinaryOperationType::Multiply; + else if (getType(index, 1) == "/") + type = FlowGraph::BinaryOperationType::Divide; + else if (getType(index, 1) == "%") + type = FlowGraph::BinaryOperationType::Modulo; + else + throw std::runtime_error("ICE: multiplicative-expression: Unknown operand: "s + getType(index, 1)); + + std::shared_ptr<FlowGraph::Node> node {std::make_shared<FlowGraph::BinaryOperation>(type, destination, lastOp0->destination(), lastOp1->destination())}; |