ast: ban signed EXP, fixing #1246

This commit is contained in:
Yoichi Hirai 2016-10-24 20:12:31 +02:00
parent 578b02bb37
commit 3ca5900b8c
No known key found for this signature in database
GPG Key ID: E7B75D080FCF7992
2 changed files with 5 additions and 1 deletions

View File

@ -3,6 +3,7 @@
Features: Features:
Bugfixes: Bugfixes:
* Type checker: forbid signed exponential that led to an incorrect use of EXP opcode.
### 0.4.3 (2016-10-25) ### 0.4.3 (2016-10-25)

View File

@ -349,11 +349,14 @@ TypePointer IntegerType::binaryOperatorResult(Token::Value _operator, TypePointe
return commonType; return commonType;
if (Token::isBooleanOp(_operator)) if (Token::isBooleanOp(_operator))
return TypePointer(); return TypePointer();
// Nothing else can be done with addresses
if (auto intType = dynamic_pointer_cast<IntegerType const>(commonType)) if (auto intType = dynamic_pointer_cast<IntegerType const>(commonType))
{ {
// Nothing else can be done with addresses
if (intType->isAddress()) if (intType->isAddress())
return TypePointer(); return TypePointer();
// Signed EXP is not allowed
if (Token::Exp == _operator && intType->isSigned())
return TypePointer();
} }
else if (auto fixType = dynamic_pointer_cast<FixedPointType const>(commonType)) else if (auto fixType = dynamic_pointer_cast<FixedPointType const>(commonType))
if (Token::Exp == _operator) if (Token::Exp == _operator)