mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Disallow statements containing empty blocks e.g., empty if, for, function definition
This commit is contained in:
		
							parent
							
								
									aaa434dad9
								
							
						
					
					
						commit
						f78414b333
					
				| @ -1302,19 +1302,23 @@ void ProtoConverter::visit(Statement const& _x) | |||||||
| 			visit(_x.assignment()); | 			visit(_x.assignment()); | ||||||
| 		break; | 		break; | ||||||
| 	case Statement::kIfstmt: | 	case Statement::kIfstmt: | ||||||
| 		visit(_x.ifstmt()); | 		if (_x.ifstmt().if_body().statements_size() > 0) | ||||||
|  | 			visit(_x.ifstmt()); | ||||||
| 		break; | 		break; | ||||||
| 	case Statement::kStorageFunc: | 	case Statement::kStorageFunc: | ||||||
| 		visit(_x.storage_func()); | 		visit(_x.storage_func()); | ||||||
| 		break; | 		break; | ||||||
| 	case Statement::kBlockstmt: | 	case Statement::kBlockstmt: | ||||||
| 		visit(_x.blockstmt()); | 		if (_x.blockstmt().statements_size() > 0) | ||||||
|  | 			visit(_x.blockstmt()); | ||||||
| 		break; | 		break; | ||||||
| 	case Statement::kForstmt: | 	case Statement::kForstmt: | ||||||
| 		visit(_x.forstmt()); | 		if (_x.forstmt().for_body().statements_size() > 0) | ||||||
|  | 			visit(_x.forstmt()); | ||||||
| 		break; | 		break; | ||||||
| 	case Statement::kBoundedforstmt: | 	case Statement::kBoundedforstmt: | ||||||
| 		visit(_x.boundedforstmt()); | 		if (_x.boundedforstmt().for_body().statements_size() > 0) | ||||||
|  | 			visit(_x.boundedforstmt()); | ||||||
| 		break; | 		break; | ||||||
| 	case Statement::kSwitchstmt: | 	case Statement::kSwitchstmt: | ||||||
| 		visit(_x.switchstmt()); | 		visit(_x.switchstmt()); | ||||||
| @ -1346,8 +1350,9 @@ void ProtoConverter::visit(Statement const& _x) | |||||||
| 		visit(_x.functioncall()); | 		visit(_x.functioncall()); | ||||||
| 		break; | 		break; | ||||||
| 	case Statement::kFuncdef: | 	case Statement::kFuncdef: | ||||||
| 		if (!m_inForInitScope) | 		if (_x.funcdef().block().statements_size() > 0) | ||||||
| 			visit(_x.funcdef()); | 			if (!m_inForInitScope) | ||||||
|  | 				visit(_x.funcdef()); | ||||||
| 		break; | 		break; | ||||||
| 	case Statement::kPop: | 	case Statement::kPop: | ||||||
| 		visit(_x.pop()); | 		visit(_x.pop()); | ||||||
| @ -1524,7 +1529,7 @@ void ProtoConverter::visit(Block const& _x) | |||||||
| 	// scope belongs to for-init (in which function declarations
 | 	// scope belongs to for-init (in which function declarations
 | ||||||
| 	// are forbidden).
 | 	// are forbidden).
 | ||||||
| 	for (auto const& statement: _x.statements()) | 	for (auto const& statement: _x.statements()) | ||||||
| 		if (statement.has_funcdef() && !m_inForInitScope) | 		if (statement.has_funcdef() && statement.funcdef().block().statements_size() > 0 && !m_inForInitScope) | ||||||
| 			registerFunction(&statement.funcdef()); | 			registerFunction(&statement.funcdef()); | ||||||
| 
 | 
 | ||||||
| 	if (_x.statements_size() > 0) | 	if (_x.statements_size() > 0) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user