diff --git a/lib/calculate.h b/lib/calculate.h index 084285c67..663d2939a 100644 --- a/lib/calculate.h +++ b/lib/calculate.h @@ -111,6 +111,8 @@ R calculate(const std::string& s, const T& x, const T& y, bool* error = nullptr) return wrap(x >= y); case '<=': return wrap(x <= y); + case '<=>': + return wrap(x - y); } throw InternalError(nullptr, "Unknown operator: " + s); } diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index fcb732f04..1d910a880 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1075,6 +1075,13 @@ private: ASSERT_EQUALS(22, values.back().intvalue); } + // #10251 starship operator + code = "struct X {};\n" + "auto operator<=>(const X & a, const X & b) -> decltype(1 <=> 2) {\n" + " return std::strong_ordering::less;\n" + "}\n"; + tokenValues(code, "<=>"); // don't throw + // Comparison of string values = removeImpossible(tokenValues("f(\"xyz\" == \"xyz\");", "==")); // implementation defined ASSERT_EQUALS(0U, values.size()); // <- no value