@@ -439,18 +439,19 @@ doSimplifyAssignments(AST **astptr, int insertCasts, int atTopLevel)
439
439
break ;
440
440
case K_INCREMENT :
441
441
case K_DECREMENT :
442
+ int newop = (op == K_DECREMENT ) ? '-' : '+' ;
442
443
/* for ++ and --, handle floats and 64 bit integers by turning into i = i+1 */
443
444
/* specifically: i++ -> (tmp = i, i = i+1, tmp)
444
445
++i -> (i = i+1, i) */
445
446
if (ast -> left ) {
446
447
/* i++ case */
447
448
AST * typ = ExprType (ast -> left );
448
449
if (typ ) {
449
- if (IsFloatType (typ ) || IsInt64Type (typ )) {
450
+ if (IsFloatType (typ ) || IsInt64Type (typ ) || IsBoolType ( typ ) ) {
450
451
AstReportAs (ast , & saveinfo );
451
452
AST * temp = AstTempLocalVariable ("_temp_" , typ );
452
453
AST * save = AstAssign (temp , ast -> left );
453
- AST * update = AstAssign (ast -> left , AstOperator ('+' , ast -> left , AstInteger (1 )));
454
+ AST * update = AstAssign (ast -> left , AstOperator (newop , ast -> left , AstInteger (1 )));
454
455
455
456
ast = * astptr = NewAST (AST_SEQUENCE ,
456
457
NewAST (AST_SEQUENCE , save , update ),
@@ -462,11 +463,11 @@ doSimplifyAssignments(AST **astptr, int insertCasts, int atTopLevel)
462
463
AST * ident = ast -> right ;
463
464
AST * typ = ExprType (ident );
464
465
if (typ ) {
465
- if (IsFloatType (typ ) || IsInt64Type (typ )) {
466
+ if (IsFloatType (typ ) || IsInt64Type (typ ) || IsBoolType ( typ ) ) {
466
467
ast -> kind = AST_ASSIGN ;
467
468
ast -> d .ival = K_ASSIGN ;
468
469
ast -> left = ident ;
469
- ast -> right = AstOperator ('+' , ident , AstInteger (1 ));
470
+ ast -> right = AstOperator (newop , ident , AstInteger (1 ));
470
471
}
471
472
}
472
473
}
0 commit comments