diff --git a/Changelog.md b/Changelog.md index 71ccea0df..159ec5187 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ Compiler Features: Bugfixes: + * Commandline Interface: It is no longer possible to specify both ``--optimize-yul`` and ``--no-optimize-yul`` at the same time. * SMTChecker: Fix encoding of side-effects inside ``if`` and ``ternary conditional``statements in the BMC engine. diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 1f11fc57c..814470126 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -1146,6 +1146,13 @@ void CommandLineParser::processArgs() m_options.output.eofVersion = 1; } + if (m_args.count(g_strNoOptimizeYul) > 0 && m_args.count(g_strOptimizeYul) > 0) + solThrow( + CommandLineValidationError, + "Options --" + g_strOptimizeYul + " and --" + g_strNoOptimizeYul + " cannot be used together." + ); + + // We deliberately ignore --optimize-yul m_options.optimizer.enabled = (m_args.count(g_strOptimize) > 0); m_options.optimizer.noOptimizeYul = (m_args.count(g_strNoOptimizeYul) > 0); if (!m_args[g_strOptimizeRuns].defaulted()) diff --git a/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/args b/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/args new file mode 100644 index 000000000..ce566d3e0 --- /dev/null +++ b/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/args @@ -0,0 +1 @@ +--optimize-yul --no-optimize-yul diff --git a/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/err b/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/err new file mode 100644 index 000000000..43c54c2f3 --- /dev/null +++ b/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/err @@ -0,0 +1 @@ +Options --optimize-yul and --no-optimize-yul cannot be used together. diff --git a/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/exit b/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/exit new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/exit @@ -0,0 +1 @@ +1 diff --git a/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/input.sol b/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/input.sol new file mode 100644 index 000000000..a32f63f78 --- /dev/null +++ b/test/cmdlineTests/optimizer_enabled_invalid_yul_optimizer_enabled_and_disabled/input.sol @@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity *; diff --git a/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/args b/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/args new file mode 100644 index 000000000..cbefff3e9 --- /dev/null +++ b/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/args @@ -0,0 +1 @@ +--strict-assembly --optimize-yul --no-optimize-yul diff --git a/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/err b/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/err new file mode 100644 index 000000000..43c54c2f3 --- /dev/null +++ b/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/err @@ -0,0 +1 @@ +Options --optimize-yul and --no-optimize-yul cannot be used together. diff --git a/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/exit b/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/exit new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/exit @@ -0,0 +1 @@ +1 diff --git a/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/input.yul b/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/input.yul new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/test/cmdlineTests/strict_asm_optimizer_invalid_yul_optimizer_enabled_and_disabled/input.yul @@ -0,0 +1 @@ +{}