diff --git a/oscar64/Declaration.cpp b/oscar64/Declaration.cpp index cc45292..c7e2c4a 100644 --- a/oscar64/Declaration.cpp +++ b/oscar64/Declaration.cpp @@ -502,8 +502,16 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio { Expression* ex = new Expression(mLocation, EX_CONSTANT); Declaration* dec = new Declaration(mLocation, DT_CONST_INTEGER); - dec->mBase = mLeft->mDecValue->mBase; + dec->mInteger = ~mLeft->mDecValue->mInteger; + if (mLeft->mDecValue->mBase->mSize <= 2) + { + dec->mInteger &= 0xffff; + dec->mBase = TheUnsignedIntTypeDeclaration; + } + else + dec->mBase = TheUnsignedLongTypeDeclaration; + ex->mDecValue = dec; ex->mDecType = dec->mBase; return ex; diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 4cb7cd7..70e091a 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -7281,6 +7281,18 @@ Expression* Parser::ParsePrefixExpression(bool lhs) { nexp->mDecType = TheUnsignedCharTypeDeclaration; } + else if (nexp->mToken == TK_BINARY_AND) + { + if (nexp->mDecType->mFlags & DTF_SIGNED) + { + if (nexp->mDecType->mSize == 4) + nexp->mDecType = TheUnsignedLongTypeDeclaration; + else + nexp->mDecType = TheUnsignedIntTypeDeclaration; + } + else + nexp->mDecType = nexp->mLeft->mDecType; + } else nexp->mDecType = nexp->mLeft->mDecType; }