mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
SyntaxTest::filterObtainedErrors(): Remove hard-coded preamble to match changes in setupCompiler()
This commit is contained in:
parent
6f1f0c5bbc
commit
5677211471
@ -113,20 +113,30 @@ void SyntaxTest::parseAndAnalyze()
|
|||||||
|
|
||||||
void SyntaxTest::filterObtainedErrors()
|
void SyntaxTest::filterObtainedErrors()
|
||||||
{
|
{
|
||||||
string const preamble = "pragma solidity >=0.0;\n// SPDX-License-Identifier: GPL-3.0\n";
|
|
||||||
for (auto const& currentError: filterErrors(compiler().errors(), true))
|
for (auto const& currentError: filterErrors(compiler().errors(), true))
|
||||||
{
|
{
|
||||||
int locationStart = -1, locationEnd = -1;
|
int locationStart = -1, locationEnd = -1;
|
||||||
string sourceName;
|
string sourceName;
|
||||||
if (auto location = boost::get_error_info<errinfo_sourceLocation>(*currentError))
|
if (auto location = boost::get_error_info<errinfo_sourceLocation>(*currentError))
|
||||||
{
|
{
|
||||||
|
solAssert(location->source, "");
|
||||||
|
sourceName = location->source->name();
|
||||||
|
|
||||||
|
solAssert(m_sources.count(sourceName) == 1, "");
|
||||||
|
int preambleSize = static_cast<int>(location->source->source().size()) - static_cast<int>(m_sources[sourceName].size());
|
||||||
|
solAssert(preambleSize >= 0, "");
|
||||||
|
|
||||||
// ignore the version & license pragma inserted by the testing tool when calculating locations.
|
// ignore the version & license pragma inserted by the testing tool when calculating locations.
|
||||||
if (location->start >= static_cast<int>(preamble.size()))
|
if (location->start != -1)
|
||||||
locationStart = location->start - static_cast<int>(preamble.size());
|
{
|
||||||
if (location->end >= static_cast<int>(preamble.size()))
|
solAssert(location->start >= preambleSize, "");
|
||||||
locationEnd = location->end - static_cast<int>(preamble.size());
|
locationStart = location->start - preambleSize;
|
||||||
if (location->source)
|
}
|
||||||
sourceName = location->source->name();
|
if (location->end != -1)
|
||||||
|
{
|
||||||
|
solAssert(location->end >= preambleSize, "");
|
||||||
|
locationEnd = location->end - preambleSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_errorList.emplace_back(SyntaxTestError{
|
m_errorList.emplace_back(SyntaxTestError{
|
||||||
currentError->typeName(),
|
currentError->typeName(),
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
import "~~~some-long-unlikely-file-name-12";
|
||||||
|
import "~~~some-long-unlikely-file-name-456";
|
||||||
|
import "~~~some-long-unlikely-file-name-7890";
|
||||||
|
// This test is here to verify that the license/pragma preamble added by the test suite does not
|
||||||
|
// affect source locations in error messages. Positions in messages below should start at 0 and
|
||||||
|
// there should be no gaps between the ranges.
|
||||||
|
// ----
|
||||||
|
// ParserError 6275: (0-44): Source "~~~some-long-unlikely-file-name-12" not found: File not supplied initially.
|
||||||
|
// ParserError 6275: (45-90): Source "~~~some-long-unlikely-file-name-456" not found: File not supplied initially.
|
||||||
|
// ParserError 6275: (91-137): Source "~~~some-long-unlikely-file-name-7890" not found: File not supplied initially.
|
Loading…
Reference in New Issue
Block a user