mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Do not allow shadowing inline assembly instructions with variables
This commit is contained in:
parent
ba9a045002
commit
900c56d996
@ -10,6 +10,7 @@ Features:
|
||||
|
||||
Bugfixes:
|
||||
* Code generator: Allow recursive structs.
|
||||
* Inline assembly: reject shadowing instructions by variables.
|
||||
* Type checker: Allow multiple events of the same name (but with different arities or argument types)
|
||||
|
||||
### 0.4.8 (2017-01-13)
|
||||
|
@ -130,7 +130,7 @@ assembly::Statement Parser::parseExpression()
|
||||
return operation;
|
||||
}
|
||||
|
||||
assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
|
||||
std::map<string, dev::solidity::Instruction> Parser::getInstructions()
|
||||
{
|
||||
// Allowed instructions, lowercase names.
|
||||
static map<string, dev::solidity::Instruction> s_instructions;
|
||||
@ -151,6 +151,12 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
|
||||
// add alias for selfdestruct
|
||||
s_instructions["selfdestruct"] = solidity::Instruction::SUICIDE;
|
||||
}
|
||||
return s_instructions;
|
||||
}
|
||||
|
||||
assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
|
||||
{
|
||||
map<string, dev::solidity::Instruction> s_instructions = getInstructions();
|
||||
|
||||
Statement ret;
|
||||
switch (m_scanner->currentToken())
|
||||
@ -204,9 +210,12 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
|
||||
|
||||
assembly::VariableDeclaration Parser::parseVariableDeclaration()
|
||||
{
|
||||
map<string, dev::solidity::Instruction> s_instructions = getInstructions();
|
||||
VariableDeclaration varDecl = createWithLocation<VariableDeclaration>();
|
||||
expectToken(Token::Let);
|
||||
varDecl.name = m_scanner->currentLiteral();
|
||||
if (s_instructions.count(varDecl.name))
|
||||
fatalParserError("Cannot shadow instructions with variable declaration.");
|
||||
expectToken(Token::Identifier);
|
||||
expectToken(Token::Colon);
|
||||
expectToken(Token::Assign);
|
||||
|
@ -64,6 +64,7 @@ protected:
|
||||
Statement parseStatement();
|
||||
/// Parses a functional expression that has to push exactly one stack element
|
||||
Statement parseExpression();
|
||||
std::map<std::string, dev::solidity::Instruction> getInstructions();
|
||||
Statement parseElementaryOperation(bool _onlySinglePusher = false);
|
||||
VariableDeclaration parseVariableDeclaration();
|
||||
FunctionalInstruction parseFunctionalInstruction(Statement&& _instruction);
|
||||
|
Loading…
Reference in New Issue
Block a user