mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
added checks to prevent the self assignment
This commit is contained in:
parent
090e581fe8
commit
8b433edc4e
@ -41,8 +41,21 @@ struct SourceLocation
|
|||||||
SourceLocation(): start(-1), end(-1) { }
|
SourceLocation(): start(-1), end(-1) { }
|
||||||
|
|
||||||
SourceLocation(SourceLocation const& _other):
|
SourceLocation(SourceLocation const& _other):
|
||||||
start(_other.start), end(_other.end), sourceName(_other.sourceName) {}
|
start(_other.start),
|
||||||
SourceLocation& operator=(SourceLocation const& _other) { start = _other.start; end = _other.end; sourceName = _other.sourceName; return *this;}
|
end(_other.end),
|
||||||
|
sourceName(_other.sourceName)
|
||||||
|
{}
|
||||||
|
|
||||||
|
SourceLocation& operator=(SourceLocation const& _other)
|
||||||
|
{
|
||||||
|
if (&_other == this)
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
start = _other.start;
|
||||||
|
end = _other.end;
|
||||||
|
sourceName = _other.sourceName;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator==(SourceLocation const& _other) const { return start == _other.start && end == _other.end;}
|
bool operator==(SourceLocation const& _other) const { return start == _other.start && end == _other.end;}
|
||||||
bool operator!=(SourceLocation const& _other) const { return !operator==(_other); }
|
bool operator!=(SourceLocation const& _other) const { return !operator==(_other); }
|
||||||
|
Loading…
Reference in New Issue
Block a user