allow some implicit pointer casts, fix pointer add,sub
authorMatthias Braun <matze@braunis.de>
Wed, 14 Nov 2007 16:26:01 +0000 (16:26 +0000)
committerMatthias Braun <matze@braunis.de>
Wed, 14 Nov 2007 16:26:01 +0000 (16:26 +0000)
[r18392]

parser.c

index fb011da..31fd8d2 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2331,6 +2331,17 @@ static expression_t *create_implicit_cast(expression_t *expression,
 
                return create_cast_expression(expression, dest_type);
        }
+       if(dest_type->type == TYPE_POINTER) {
+               if(source_type->type == TYPE_POINTER) {
+                       if(!pointers_compatible(source_type, dest_type)) {
+                               type_error_incompatible("can't implicitely cast types",
+                                               expression->source_position,
+                                               source_type, dest_type);
+                       } else {
+                               return create_cast_expression(expression, dest_type);
+                       }
+               }
+       }
 
        panic("casting of non-atomic types not implemented yet");
 }
@@ -3216,7 +3227,10 @@ static statement_t *parse_return(void)
                }
        } else {
                return_value = NULL;
-               parse_warning("'return' without value, in function retruning non-void");
+               if(return_type != type_void) {
+                       parse_warning("'return' without value, in function returning "
+                                     "non-void");
+               }
        }
        statement->return_value = return_value;