comparison dmd/expression.c @ 1012:39cf8fa483fd

Error gracefully for +=, -=, *=, /= if rhs is complex but lhs isn't.
author Christian Kamm <kamm incasoftware de>
date Sat, 28 Feb 2009 19:58:30 +0100
parents ea82e2077f9d
children b30fe7e1dbb9
comparison
equal deleted inserted replaced
1011:010b8b67de1a 1012:39cf8fa483fd
8029 { 8029 {
8030 assert(global.errors || e2->type->isfloating()); 8030 assert(global.errors || e2->type->isfloating());
8031 e2 = e2->castTo(sc, e1->type); 8031 e2 = e2->castTo(sc, e1->type);
8032 } 8032 }
8033 e = this; 8033 e = this;
8034
8035 if (e2->type->iscomplex() && !type->iscomplex())
8036 error("Cannot assign %s to %s", e2->type->toChars(), type->toChars());
8034 } 8037 }
8035 } 8038 }
8036 return e; 8039 return e;
8037 } 8040 }
8038 8041
8078 { 8081 {
8079 assert(e2->type->isfloating()); 8082 assert(e2->type->isfloating());
8080 e2 = e2->castTo(sc, e1->type); 8083 e2 = e2->castTo(sc, e1->type);
8081 } 8084 }
8082 e = this; 8085 e = this;
8086
8087 if (e2->type->iscomplex() && !type->iscomplex())
8088 error("Cannot assign %s to %s", e2->type->toChars(), type->toChars());
8083 } 8089 }
8084 return e; 8090 return e;
8085 } 8091 }
8086 8092
8087 /************************************************************/ 8093 /************************************************************/
8199 assert(0); 8205 assert(0);
8200 } 8206 }
8201 e2 = e2->castTo(sc, t2); 8207 e2 = e2->castTo(sc, t2);
8202 } 8208 }
8203 } 8209 }
8210
8211 if (e2->type->iscomplex() && !type->iscomplex())
8212 error("Cannot assign %s to %s", e2->type->toChars(), type->toChars());
8204 } 8213 }
8205 return this; 8214 return this;
8206 } 8215 }
8207 8216
8208 /************************************************************/ 8217 /************************************************************/
8265 e = new AssignExp(loc, e1, e2); 8274 e = new AssignExp(loc, e1, e2);
8266 e->type = t1; 8275 e->type = t1;
8267 return e; 8276 return e;
8268 } 8277 }
8269 } 8278 }
8279
8280 if (e2->type->iscomplex() && !type->iscomplex())
8281 error("Cannot assign %s to %s", e2->type->toChars(), type->toChars());
8282
8270 return this; 8283 return this;
8271 } 8284 }
8272 8285
8273 /************************************************************/ 8286 /************************************************************/
8274 8287