code cleaned a little bit too much ;-)
[fw/sdcc] / src / SDCC.y
index 4a38510e5b61aa71084b12754dc97a0cd909c666..49788ecbfeb77e32a89ef36ceae48b7937138d5b 100644 (file)
@@ -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
@@ -597,7 +565,7 @@ type_specifier
           /* add this to the storage class specifier  */
            SPEC_ABSA($1) = 1;   /* set the absolute addr flag */
            /* now get the abs addr from value */
-           SPEC_ADDR($1) = (int) floatFromVal(constExprValue($3,TRUE)) ;
+           SPEC_ADDR($1) = (unsigned) floatFromVal(constExprValue($3,TRUE)) ;
         }
    ;
 
@@ -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);
@@ -1373,12 +1341,17 @@ abstract_declarator2
           
        FUNC_HASVARARGS(p) = IS_VARG($4);
        FUNC_ARGS(p) = reverseVal($4);
-            
+
        /* nest level was incremented to take care of the parms  */
        NestLevel-- ;
        currBlockno--;
-       p->next = $1;
-       $$ = p;
+       if (!$1) {
+         /* ((void (code *) (void)) 0) () */
+         $1=newLink(DECLARATOR);
+         DCL_TYPE($1)=CPOINTER;
+         $$ = $1;
+       }
+       $1->next=p;
 
        // remove the symbol args (if any)
        cleanUpLevel(SymbolTab,NestLevel+1);