Skip to content

Commit

Permalink
#1056, fix lexer to return correct integer types
Browse files Browse the repository at this point in the history
  • Loading branch information
LADSoft committed Nov 26, 2024
1 parent 38c6665 commit b4540ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/occparse/expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ static EXPRESSION* GetConstMakeExpression(SYMBOL* sym)
return MakeExpression(ExpressionNode::const_, sym);
return nullptr;
}
int count3;
static LexList* variableName(LexList* lex, SYMBOL* funcsp, Type* atp, Type** tp, EXPRESSION** exp, bool* ismutable, int flags)
{
char idname[512];
Expand Down
23 changes: 15 additions & 8 deletions src/occparse/lex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,27 +1488,34 @@ LexType getNumber(const unsigned char** ptr, const unsigned char** end, unsigned
}
if (lastst == LexType::i_) /* no qualifiers */
{
if (*ival > INT_MAX)
if (*ival > INT_MAX || radix != 10)
{
lastst = LexType::ui_;
if (radix == 10 || (unsigned long long)*ival > UINT_MAX)
if ((unsigned long long)*ival > UINT_MAX)
{
lastst = LexType::l_;
if (*ival > LONG_MAX)
if (radix != 10 || *ival > LONG_MAX || *ival < LONG_MIN)
{
lastst = LexType::ul_;
if (radix == 10 || (unsigned long long)*ival > ULONG_MAX)
if ((unsigned long long)*ival > ULONG_MAX)
{
if (radix == 10 || *ival > ULLONG_MAX)
lastst = LexType::ll_;
if (radix != 10 || *ival > LLONG_MAX || *ival < LLONG_MIN)
{
lastst = LexType::ll_;
}
else
lastst = LexType::ull_;
}
}
}
}
}
else if (*ival < INT_MIN)
{
lastst = LexType::l_;
if (*ival < LONG_MIN)
{
lastst = LexType::ll_;
}
}
}
}
else
Expand Down

0 comments on commit b4540ca

Please sign in to comment.