X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCC.y;h=49788ecbfeb77e32a89ef36ceae48b7937138d5b;hb=e29becd95456cf7510a45c41af35bee5fa362ba8;hp=a5a0f32994af2952e10d8afc223b5baf109d6383;hpb=a8b6b80ff9fcad4aba5bb339e95db62f75f9eb61;p=fw%2Fsdcc diff --git a/src/SDCC.y b/src/SDCC.y index a5a0f329..49788ecb 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -186,9 +186,9 @@ function_attribute ; function_attributes - : USING CONSTANT { + : USING constant_expr { $$ = newLink(SPECIFIER) ; - FUNC_REGBANK($$) = (int) floatFromVal($2); + FUNC_REGBANK($$) = (int) floatFromVal(constExprValue($2,TRUE)); } | REENTRANT { $$ = newLink (SPECIFIER); FUNC_ISREENT($$)=1; @@ -334,40 +334,16 @@ shift_expr relational_expr : shift_expr - | relational_expr '<' shift_expr { - $$ = (port->lt_nge ? - newNode('!',newNode(GE_OP,$1,$3),NULL) : - newNode('<', $1,$3)); - } - | relational_expr '>' shift_expr { - $$ = (port->gt_nle ? - newNode('!',newNode(LE_OP,$1,$3),NULL) : - newNode('>',$1,$3)); - } - | relational_expr LE_OP shift_expr { - $$ = (port->le_ngt ? - newNode('!', newNode('>', $1 , $3 ), NULL) : - newNode(LE_OP,$1,$3)); - } - | relational_expr GE_OP shift_expr { - $$ = (port->ge_nlt ? - newNode('!', newNode('<', $1 , $3 ), NULL) : - newNode(GE_OP,$1,$3)); - } + | relational_expr '<' shift_expr { $$ = newNode('<', $1,$3);} + | relational_expr '>' shift_expr { $$ = newNode('>', $1,$3);} + | relational_expr LE_OP shift_expr { $$ = newNode(LE_OP,$1,$3);} + | relational_expr GE_OP shift_expr { $$ = newNode(GE_OP,$1,$3);} ; equality_expr : relational_expr - | equality_expr EQ_OP relational_expr { - $$ = (port->eq_nne ? - newNode('!',newNode(NE_OP,$1,$3),NULL) : - newNode(EQ_OP,$1,$3)); - } - | equality_expr NE_OP relational_expr { - $$ = (port->ne_neq ? - newNode('!', newNode(EQ_OP,$1,$3), NULL) : - newNode(NE_OP,$1,$3)); - } + | equality_expr EQ_OP relational_expr { $$ = newNode(EQ_OP,$1,$3);} + | equality_expr NE_OP relational_expr { $$ = newNode(NE_OP,$1,$3);} ; and_expr @@ -416,45 +392,37 @@ assignment_expr $$ = newNode($2,$1,$3); break; case MUL_ASSIGN: - $$ = newNode('=',removePostIncDecOps(copyAst($1)), - newNode('*',removePreIncDecOps(copyAst($1)),$3)); + $$ = createRMW($1, '*', $3); break; case DIV_ASSIGN: - $$ = newNode('=',removePostIncDecOps(copyAst($1)), - newNode('/',removePreIncDecOps(copyAst($1)),$3)); + $$ = createRMW($1, '/', $3); break; case MOD_ASSIGN: - $$ = newNode('=',removePostIncDecOps(copyAst($1)), - newNode('%',removePreIncDecOps(copyAst($1)),$3)); + $$ = createRMW($1, '%', $3); break; case ADD_ASSIGN: - $$ = newNode('=',removePostIncDecOps(copyAst($1)), - newNode('+',removePreIncDecOps(copyAst($1)),$3)); + $$ = createRMW($1, '+', $3); break; case SUB_ASSIGN: - $$ = newNode('=',removePostIncDecOps(copyAst($1)), - newNode('-',removePreIncDecOps(copyAst($1)),$3)); + $$ = createRMW($1, '-', $3); break; case LEFT_ASSIGN: - $$ = newNode('=',removePostIncDecOps(copyAst($1)), - newNode(LEFT_OP,removePreIncDecOps(copyAst($1)),$3)); + $$ = createRMW($1, LEFT_OP, $3); break; case RIGHT_ASSIGN: - $$ = newNode('=',removePostIncDecOps(copyAst($1)), - newNode(RIGHT_OP,removePreIncDecOps(copyAst($1)),$3)); + $$ = createRMW($1, RIGHT_OP, $3); break; case AND_ASSIGN: - $$ = newNode('=',removePostIncDecOps(copyAst($1)), - newNode('&',removePreIncDecOps(copyAst($1)),$3)); + $$ = createRMW($1, '&', $3); break; case XOR_ASSIGN: - $$ = newNode('=',removePostIncDecOps(copyAst($1)), - newNode('^',removePreIncDecOps(copyAst($1)),$3)); + $$ = createRMW($1, '^', $3); break; case OR_ASSIGN: - /* $$ = newNode('=',$1,newNode('|',removeIncDecOps(copyAst($1)),$3)); */ - $$ = newNode('=',removePostIncDecOps(copyAst($1)), - newNode('|',removePreIncDecOps(copyAst($1)),$3)); +/* $$ = newNode('=',$1,newNode('|',removeIncDecOps(copyAst($1)),$3)); */ +/* $$ = newNode('=',removePostIncDecOps(copyAst($1)), + newNode('|',removePreIncDecOps(copyAst($1)),$3)); */ + $$ = createRMW($1, '|', $3); break; default : $$ = NULL; @@ -578,8 +546,8 @@ storage_class_specifier Interrupt_storage : INTERRUPT { $$ = INTNO_UNSPEC ; } - | INTERRUPT CONSTANT - { int intno = (int) floatFromVal($2); + | INTERRUPT constant_expr + { int intno = (int) floatFromVal(constExprValue($2,TRUE)); if ((intno >= 0) && (intno <= INTNO_MAX)) $$ = intno; else @@ -909,9 +877,9 @@ struct_declarator_list struct_declarator : declarator | ':' constant_expr { - int bitsize; + unsigned int bitsize; $$ = newSymbol (genSymName(NestLevel),NestLevel) ; - bitsize= (int) floatFromVal(constExprValue($2,TRUE)); + bitsize= (unsigned int) floatFromVal(constExprValue($2,TRUE)); if (bitsize > (port->s.int_size * 8)) { bitsize = port->s.int_size * 8; werror(E_BITFLD_SIZE, bitsize); @@ -922,8 +890,8 @@ struct_declarator } | declarator ':' constant_expr { - int bitsize; - bitsize= (int) floatFromVal(constExprValue($3,TRUE)); + unsigned int bitsize; + bitsize= (unsigned int) floatFromVal(constExprValue($3,TRUE)); if (bitsize > (port->s.int_size * 8)) { bitsize = port->s.int_size * 8; werror(E_BITFLD_SIZE, bitsize);