diff --git a/runtime-testsuite/resources/org/antlr/v4/test/runtime/descriptors/ParserExec/ListLabelsOnRuleRefStartOfAlt.txt b/runtime-testsuite/resources/org/antlr/v4/test/runtime/descriptors/ParserExec/ListLabelsOnRuleRefStartOfAlt.txt index ac6963e588..8a553b47b2 100644 --- a/runtime-testsuite/resources/org/antlr/v4/test/runtime/descriptors/ParserExec/ListLabelsOnRuleRefStartOfAlt.txt +++ b/runtime-testsuite/resources/org/antlr/v4/test/runtime/descriptors/ParserExec/ListLabelsOnRuleRefStartOfAlt.txt @@ -11,9 +11,7 @@ expression @after { } - : op=NOT args+=expression - | args+=expression (op=AND args+=expression)+ - | args+=expression (op=OR args+=expression)+ + : args+=expression (op=AND args+=expression)+ | IDENTIFIER ; @@ -28,6 +26,3 @@ expression [input] a and b - -[skip] -Cpp \ No newline at end of file diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/cpp/CppRunner.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/cpp/CppRunner.java index dec7336ec1..722eb55b8c 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/cpp/CppRunner.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/cpp/CppRunner.java @@ -32,7 +32,8 @@ * * In test dir with generated test code: * - * clang++ -g -std=c++17 -I /Users/parrt/antlr/code/antlr4/runtime/Cpp/runtime/src -L. -lantlr4-runtime *.cpp + * clang++ -g -std=c++17 -I /Users/parrt/antlr/code/antlr4/runtime/Cpp/runtime/src \ + * -L/Users/parrt/antlr/code/antlr4/runtime/Cpp/dist -lantlr4-runtime *.cpp * ./a.out input * * $ lldb ./a.out input diff --git a/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp b/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp index 7dcc011d1d..cdea251832 100755 --- a/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +++ b/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp @@ -75,11 +75,17 @@ bool ArrayPredictionContext::equals(const PredictionContext &other) const { return false; } const auto &array = downCast(other); - return returnStates.size() == array.returnStates.size() && - parents.size() == array.parents.size() && - cachedHashCodeEqual(cachedHashCode(), array.cachedHashCode()) && - std::memcmp(returnStates.data(), array.returnStates.data(), returnStates.size() * sizeof(decltype(returnStates)::value_type)) == 0 && - std::equal(parents.begin(), parents.end(), array.parents.begin(), predictionContextEqual); + const bool sameSize = returnStates.size() == array.returnStates.size() && + parents.size() == array.parents.size(); + const bool sameHash = cachedHashCodeEqual(cachedHashCode(), array.cachedHashCode()); + const size_t stateSizeBytes = sizeof(decltype(returnStates)::value_type); + const bool stateArraysEqual = + std::memcmp(returnStates.data(), array.returnStates.data(), + returnStates.size() * stateSizeBytes) == 0; + // stack of contexts is the same + const bool parentCtxEqual = std::equal(parents.begin(), parents.end(), array.parents.begin(), + predictionContextEqual); + return sameSize && sameHash && stateArraysEqual && parentCtxEqual; } std::string ArrayPredictionContext::toString() const {