Changeset 7c782af for src/ResolvExpr
- Timestamp:
- Feb 16, 2018, 4:22:25 PM (8 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, resolv-new, with_gc
- Children:
- 5964127
- Parents:
- c71b256 (diff), 62cd621 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/ResolvExpr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
rc71b256 r7c782af 239 239 std::cerr << "No reasonable alternatives for expression " << expr << std::endl; 240 240 ) 241 throw SemanticError( "No reasonable alternatives for expression ", expr);241 throw SemanticError( expr, "No reasonable alternatives for expression " ); 242 242 } 243 243 if ( prune ) { … … 257 257 stream << "Alternatives are:\n"; 258 258 printAlts( winners, stream, 1 ); 259 throw SemanticError( stream.str() );259 throw SemanticError( expr->location, stream.str() ); 260 260 } 261 261 alternatives = move(pruned); … … 494 494 return; 495 495 } else if ( level >= recursionLimit ) { 496 throw SemanticError( "Too many recursive assertions" );496 throw SemanticError( newAlt.expr->location, "Too many recursive assertions" ); 497 497 } else { 498 498 AssertionSet newerNeed; … … 1408 1408 findMinCost( finder.alternatives.begin(), finder.alternatives.end(), back_inserter( winners ) ); 1409 1409 if ( winners.size() != 1 ) { 1410 throw SemanticError( "Ambiguous expression in sizeof operand: ", sizeofExpr->get_expr());1410 throw SemanticError( sizeofExpr->get_expr(), "Ambiguous expression in sizeof operand: " ); 1411 1411 } // if 1412 1412 // return the lowest cost alternative for the argument … … 1429 1429 findMinCost( finder.alternatives.begin(), finder.alternatives.end(), back_inserter( winners ) ); 1430 1430 if ( winners.size() != 1 ) { 1431 throw SemanticError( "Ambiguous expression in alignof operand: ", alignofExpr->get_expr());1431 throw SemanticError( alignofExpr->get_expr(), "Ambiguous expression in alignof operand: " ); 1432 1432 } // if 1433 1433 // return the lowest cost alternative for the argument -
src/ResolvExpr/CurrentObject.cc
rc71b256 r7c782af 141 141 base = at->get_base(); 142 142 memberIter = createMemberIterator( base ); 143 if ( at->isVarLen ) throw SemanticError( "VLA initialization does not support @=", at);143 if ( at->isVarLen ) throw SemanticError( at, "VLA initialization does not support @=" ); 144 144 setSize( at->get_dimension() ); 145 145 } … … 156 156 PRINT( std::cerr << "array type with size: " << size << std::endl; ) 157 157 } catch ( SemanticError & ) { 158 throw SemanticError( "Constant expression of non-integral type in array dimension: ", expr);158 throw SemanticError( expr, "Constant expression of non-integral type in array dimension: " ); 159 159 } 160 160 } else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) { … … 179 179 index = constExpr->intValue(); 180 180 } catch( SemanticError & ) { 181 throw SemanticError( "Constant expression of non-integral type in array designator: ", expr);181 throw SemanticError( expr, "Constant expression of non-integral type in array designator: " ); 182 182 } 183 183 } else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) { … … 532 532 } // for 533 533 if ( desigAlts.size() > 1 ) { 534 throw SemanticError( toString("Too many alternatives (", desigAlts.size(), ") for designation: "), designation);534 throw SemanticError( designation, toString("Too many alternatives (", desigAlts.size(), ") for designation: ") ); 535 535 } else if ( desigAlts.size() == 0 ) { 536 throw SemanticError( "No reasonable alternatives for designation: ", designation);536 throw SemanticError( designation, "No reasonable alternatives for designation: " ); 537 537 } 538 538 DesignatorChain & d = desigAlts.back(); -
src/ResolvExpr/Resolver.cc
rc71b256 r7c782af 174 174 findMinCost( candidates.begin(), candidates.end(), back_inserter( winners ) ); 175 175 if ( winners.size() == 0 ) { 176 throw SemanticError( toString( "No reasonable alternatives for ", kindStr, (kindStr != "" ? " " : ""), "expression: "), untyped);176 throw SemanticError( untyped, toString( "No reasonable alternatives for ", kindStr, (kindStr != "" ? " " : ""), "expression: ") ); 177 177 } else if ( winners.size() != 1 ) { 178 178 std::ostringstream stream; … … 181 181 stream << "Alternatives are:\n"; 182 182 printAlts( winners, stream, 1 ); 183 throw SemanticError( stream.str() );183 throw SemanticError( untyped->location, stream.str() ); 184 184 } 185 185 … … 187 187 Alternative & choice = winners.front(); 188 188 if ( findDeletedExpr( choice.expr ) ) { 189 throw SemanticError( "Unique best alternative includes deleted identifier in ", choice.expr);189 throw SemanticError( choice.expr, "Unique best alternative includes deleted identifier in " ); 190 190 } 191 191 alt = std::move( choice ); … … 484 484 ss << strict_dynamic_cast<NameExpr*>( clause.target.function )->name; 485 485 ss << "' in call to waitfor"; 486 throw SemanticError( s s.str() );486 throw SemanticError( stmt->location, ss.str() ); 487 487 } 488 488 … … 506 506 PointerType * pointer = dynamic_cast< PointerType* >( func.expr->get_result()->stripReferences() ); 507 507 if( !pointer ) { 508 throw SemanticError( "candidate not viable: not a pointer type\n", func.expr->get_result());508 throw SemanticError( func.expr->get_result(), "candidate not viable: not a pointer type\n" ); 509 509 } 510 510 511 511 FunctionType * function = dynamic_cast< FunctionType* >( pointer->get_base() ); 512 512 if( !function ) { 513 throw SemanticError( "candidate not viable: not a function type\n", pointer->get_base());513 throw SemanticError( pointer->get_base(), "candidate not viable: not a function type\n" ); 514 514 } 515 515 … … 520 520 521 521 if( !advance_to_mutex( param, param_end ) ) { 522 throw SemanticError( "candidate function not viable: no mutex parameters\n", function);522 throw SemanticError(function, "candidate function not viable: no mutex parameters\n"); 523 523 } 524 524 } … … 559 559 // We ran out of parameters but still have arguments 560 560 // this function doesn't match 561 throw SemanticError( "candidate function not viable: too many mutex arguments\n", function);561 throw SemanticError( function, "candidate function not viable: too many mutex arguments\n" ); 562 562 } 563 563 … … 571 571 (*param)->get_type()->print( ss ); 572 572 ss << "'\n"; 573 throw SemanticError( ss.str(), function);573 throw SemanticError( function, ss.str() ); 574 574 } 575 575 … … 583 583 // We ran out of arguments but still have parameters left 584 584 // this function doesn't match 585 throw SemanticError( "candidate function not viable: too few mutex arguments\n", function);585 throw SemanticError( function, "candidate function not viable: too few mutex arguments\n" ); 586 586 } 587 587 … … 610 610 611 611 // Make sure we got the right number of arguments 612 if( func_candidates.empty() ) { SemanticError top( "No alternatives for function in call to waitfor" ); top.append( errors ); throw top; }613 if( args_candidates.empty() ) { SemanticError top( "No alternatives for arguments in call to waitfor" ); top.append( errors ); throw top; }614 if( func_candidates.size() > 1 ) { SemanticError top( "Ambiguous function in call to waitfor" ); top.append( errors ); throw top; }615 if( args_candidates.size() > 1 ) { SemanticError top( "Ambiguous arguments in call to waitfor" ); top.append( errors ); throw top; }612 if( func_candidates.empty() ) { SemanticError top( stmt->location, "No alternatives for function in call to waitfor" ); top.append( errors ); throw top; } 613 if( args_candidates.empty() ) { SemanticError top( stmt->location, "No alternatives for arguments in call to waitfor" ); top.append( errors ); throw top; } 614 if( func_candidates.size() > 1 ) { SemanticError top( stmt->location, "Ambiguous function in call to waitfor" ); top.append( errors ); throw top; } 615 if( args_candidates.size() > 1 ) { SemanticError top( stmt->location, "Ambiguous arguments in call to waitfor" ); top.append( errors ); throw top; } 616 616 // TODO: need to use findDeletedExpr to ensure no deleted identifiers are used. 617 617
Note:
See TracChangeset
for help on using the changeset viewer.