| 506 | } |
| 507 | } |
| 508 | virtual void preVisitExpression ( Expression * expr ) override { |
| 509 | if ( expr->alwaysSafe && expr->userSaidItsSafe && !expr->generated ) { |
| 510 | if (func == nullptr) { |
| 511 | // we're in global scope |
| 512 | anyUnsafe = true; |
| 513 | if ( checkUnsafe ) { |
| 514 | program->error("unsafe in global initializer.", "unsafe are prohibited by CodeOfPolicies", "", |
| 515 | expr->at, CompilationError::unsafe_global); |
| 516 | } |
| 517 | return; |
| 518 | } |
| 519 | auto origin = func->getOrigin(); |
| 520 | if ( !(origin && origin->generated) && !func->generated ) |
| 521 | { |
| 522 | auto fnMod = origin ? origin->module : func->module; |
| 523 | if ( fnMod == program->thisModule.get() ) { |
| 524 | anyUnsafe = true; |
| 525 | if ( checkUnsafe ) { |
| 526 | program->error("unsafe function '" + func->getMangledName() + "'", "unsafe functions are prohibited by CodeOfPolicies", "", |
| 527 | expr->at, CompilationError::unsafe_function); |
| 528 | } |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | } |
| 533 | virtual void preVisitStructureField ( Structure * var, Structure::FieldDeclaration & decl, bool last ) override { |
| 534 | Visitor::preVisitStructureField(var, decl, last); |
| 535 | if ( noLocalClassMembers ) { |
nothing calls this directly
no test coverage detected