From 7edbd99775416a32c88acf8e9379518436905f02 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 21 Nov 2020 15:19:45 +0100 Subject: Support gcc 10 and clang 11 --- cpp.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'cpp.cpp') diff --git a/cpp.cpp b/cpp.cpp index 837eae9..61fdc0e 100644 --- a/cpp.cpp +++ b/cpp.cpp @@ -10,9 +10,6 @@ #include "grammer.h" #include "minicc.h" -#include -#include - #include #include @@ -399,7 +396,7 @@ std::unordered_map> 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> CPP::getNodeEv FlowGraph::Data destination{FlowGraph::MakeTemporaryInt(result.scope())}; - std::shared_ptr node {std::make_shared(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 node {std::make_shared(type, destination, lastOp0->destination(), lastOp1->destination())}; -- cgit v1.2.3