mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6960 from ethereum/fixAsmParser
Asm Parser: Properly consider tokens when checking for clashes with builtins.
This commit is contained in:
commit
5675b742ec
@ -384,17 +384,10 @@ Parser::ElementaryOperation Parser::parseElementaryOperation()
|
|||||||
case Token::Identifier:
|
case Token::Identifier:
|
||||||
case Token::Return:
|
case Token::Return:
|
||||||
case Token::Byte:
|
case Token::Byte:
|
||||||
|
case Token::Bool:
|
||||||
case Token::Address:
|
case Token::Address:
|
||||||
{
|
{
|
||||||
YulString literal;
|
YulString literal{currentLiteral()};
|
||||||
if (currentToken() == Token::Return)
|
|
||||||
literal = "return"_yulstring;
|
|
||||||
else if (currentToken() == Token::Byte)
|
|
||||||
literal = "byte"_yulstring;
|
|
||||||
else if (currentToken() == Token::Address)
|
|
||||||
literal = "address"_yulstring;
|
|
||||||
else
|
|
||||||
literal = YulString{currentLiteral()};
|
|
||||||
// first search the set of builtins, then the instructions.
|
// first search the set of builtins, then the instructions.
|
||||||
if (m_dialect.builtin(literal))
|
if (m_dialect.builtin(literal))
|
||||||
{
|
{
|
||||||
@ -648,26 +641,25 @@ TypedName Parser::parseTypedName()
|
|||||||
|
|
||||||
YulString Parser::expectAsmIdentifier()
|
YulString Parser::expectAsmIdentifier()
|
||||||
{
|
{
|
||||||
YulString name = YulString{currentLiteral()};
|
YulString name{currentLiteral()};
|
||||||
if (m_dialect.flavour == AsmFlavour::Yul)
|
switch (currentToken())
|
||||||
{
|
{
|
||||||
switch (currentToken())
|
case Token::Return:
|
||||||
{
|
case Token::Byte:
|
||||||
case Token::Return:
|
case Token::Address:
|
||||||
case Token::Byte:
|
case Token::Bool:
|
||||||
case Token::Address:
|
case Token::Identifier:
|
||||||
case Token::Bool:
|
break;
|
||||||
advance();
|
default:
|
||||||
return name;
|
expectToken(Token::Identifier);
|
||||||
default:
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (m_dialect.builtin(name))
|
|
||||||
|
if (m_dialect.builtin(name))
|
||||||
fatalParserError("Cannot use builtin function name \"" + name.str() + "\" as identifier name.");
|
fatalParserError("Cannot use builtin function name \"" + name.str() + "\" as identifier name.");
|
||||||
else if (instructions().count(name.str()))
|
else if (m_dialect.flavour == AsmFlavour::Loose && instructions().count(name.str()))
|
||||||
fatalParserError("Cannot use instruction names for identifier names.");
|
fatalParserError("Cannot use instruction name \"" + name.str() + "\" as identifier name.");
|
||||||
expectToken(Token::Identifier);
|
advance();
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user