Ensure that negative constants are never marked as temporary terms

issue#70
Sébastien Villemot 2020-09-23 17:28:18 +02:00
parent 571ea3eb8a
commit e4687bb976
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 3 additions and 0 deletions

View File

@ -2191,6 +2191,9 @@ UnaryOpNode::cost(const vector<vector<temporary_terms_t>> &blocks_temporary_term
int
UnaryOpNode::cost(int cost, bool is_matlab) const
{
if (op_code == UnaryOpcode::uminus && dynamic_cast<NumConstNode *>(arg))
return 0; // Cost is zero for a negative constant, as for a positive one
if (is_matlab)
// Cost for Matlab files
switch (op_code)