Changeset 787
- Timestamp:
- 12/06/10 08:48:16 (14 years ago)
- Files:
-
- trunk/src/expression.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/expression.c
r779 r787 1250 1250 { 1251 1251 // Default is 'yes' - do nothing 1252 1252 1253 1253 #ifdef DEBUG 1254 1254 if (!type) 1255 1255 dump(0); 1256 1256 #endif 1257 1257 1258 1258 // Structs can be converted to bool using opCast(bool)() 1259 1259 Type *tb = type->toBasetype(); 1260 1260 if (tb->ty == Tstruct) 1261 1261 { AggregateDeclaration *ad = ((TypeStruct *)tb)->sym; 1262 1262 /* Don't really need to check for opCast first, but by doing so we 1263 1263 * get better error messages if it isn't there. 1264 1264 */ 1265 1265 Dsymbol *fd = search_function(ad, Id::cast); 1266 1266 if (fd) 1267 1267 { 1268 1268 Expression *e = new CastExp(loc, this, Type::tbool); 1269 1269 e = e->semantic(sc); 1270 return e; 1271 } 1272 1273 // Forward to aliasthis. 1274 if (ad->aliasthis) 1275 { 1276 Expression *e = new DotIdExp(loc, this, ad->aliasthis->ident); 1277 e = e->semantic(sc); 1278 e = e->checkToBoolean(sc); 1270 1279 return e; 1271 1280 } 1272 1281 } 1273 1282 1274 1283 if (!type->checkBoolean()) 1275 1284 { if (type->toBasetype() != Type::terror) 1276 1285 error("expression %s of type %s does not have a boolean value", toChars(), type->toChars()); 1277 1286 return new ErrorExp(); 1278 1287 } 1279 1288 return this; 1280 1289 } 1281 1290 1282 1291 /**************************** 1283 1292 */ 1284 1293 1285 1294 Expression *Expression::checkToPointer() 1286 1295 { 1287 1296 //printf("Expression::checkToPointer()\n"); 1288 1297 Expression *e = this; 1289 1298
