Changeset c0bf94e
- Timestamp:
- Apr 17, 2018, 4:24:05 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 27aca84
- Parents:
- a3323db1
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
ra3323db1 rc0bf94e 211 211 if ( Unsigned && size < 2 ) { // hh or h, less than int ? 212 212 // int i = -1uh => 65535 not -1, so cast is necessary for unsigned, which unfortunately eliminates warnings for large values. 213 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) );213 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false ); 214 214 } else if ( lnth != -1 ) { // explicit length ? 215 215 if ( lnth == 5 ) { // int128 ? 216 216 size = 5; 217 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) );217 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false ); 218 218 } else { 219 ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ) );219 ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ), false ); 220 220 } // if 221 221 } // if … … 285 285 Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) ); 286 286 if ( lnth != -1 ) { // explicit length ? 287 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ) );287 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ), false ); 288 288 } // if 289 289 … … 408 408 if ( dynamic_cast< VoidType * >( targetType ) ) { 409 409 delete targetType; 410 return new CastExpr( maybeMoveBuild< Expression >(expr_node) );410 return new CastExpr( maybeMoveBuild< Expression >(expr_node), false ); 411 411 } else { 412 return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType );412 return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType, false ); 413 413 } // if 414 414 } // build_cast -
src/ResolvExpr/AlternativeFinder.cc
ra3323db1 rc0bf94e 1247 1247 } 1248 1248 1249 Expression * restructureCast( Expression * argExpr, Type * toType ) {1249 Expression * restructureCast( Expression * argExpr, Type * toType, bool isGenerated ) { 1250 1250 if ( argExpr->get_result()->size() > 1 && ! toType->isVoid() && ! dynamic_cast<ReferenceType *>( toType ) ) { 1251 1251 // Argument expression is a tuple and the target type is not void and not a reference type. … … 1262 1262 // cast each component 1263 1263 TupleIndexExpr * idx = new TupleIndexExpr( argExpr->clone(), i ); 1264 componentExprs.push_back( restructureCast( idx, toType->getComponent( i ) ) );1264 componentExprs.push_back( restructureCast( idx, toType->getComponent( i ), isGenerated ) ); 1265 1265 } 1266 1266 delete argExpr; … … 1270 1270 } else { 1271 1271 // handle normally 1272 return new CastExpr( argExpr, toType->clone() ); 1272 CastExpr * ret = new CastExpr( argExpr, toType->clone() ); 1273 ret->isGenerated = isGenerated; 1274 return ret; 1273 1275 } 1274 1276 } … … 1314 1316 // count one safe conversion for each value that is thrown away 1315 1317 thisCost.incSafe( discardedValues ); 1316 Alternative newAlt( restructureCast( alt.expr->clone(), toType ), alt.env,1318 Alternative newAlt( restructureCast( alt.expr->clone(), toType, castExpr->isGenerated ), alt.env, 1317 1319 alt.cost, thisCost ); 1318 1320 inferParameters( needAssertions, haveAssertions, newAlt, openVars, … … 1730 1732 // count one safe conversion for each value that is thrown away 1731 1733 thisCost.incSafe( discardedValues ); 1732 Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost );1734 Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType, true ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost ); 1733 1735 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) ); 1734 1736 } -
src/SynTree/Expression.cc
ra3323db1 rc0bf94e 271 271 } 272 272 273 CastExpr::CastExpr( Expression *arg _, Type *toType ) : Expression(), arg(arg_) {273 CastExpr::CastExpr( Expression *arg, Type *toType, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) { 274 274 set_result(toType); 275 275 } 276 276 277 CastExpr::CastExpr( Expression *arg _ ) : Expression(), arg(arg_) {277 CastExpr::CastExpr( Expression *arg, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) { 278 278 set_result( new VoidType( Type::Qualifiers() ) ); 279 279 } 280 280 281 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {281 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) { 282 282 } 283 283 -
src/SynTree/Expression.h
ra3323db1 rc0bf94e 188 188 public: 189 189 Expression * arg; 190 191 CastExpr( Expression * arg ); 192 CastExpr( Expression * arg, Type * toType ); 190 bool isGenerated = true; // whether this cast appeared in the source program 191 192 CastExpr( Expression * arg, bool isGenerated = true ); 193 CastExpr( Expression * arg, Type * toType, bool isGenerated = true ); 193 194 CastExpr( const CastExpr & other ); 194 195 virtual ~CastExpr();
Note: See TracChangeset
for help on using the changeset viewer.