From 40eacb19b1d6e50d36379bf1b0fa884eec1aee8f Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Fri, 1 Jul 2016 23:22:16 +0200 Subject: [PATCH] Ticket #7565: Handle numbers with several C++14 integer separators. --- lib/mathlib.cpp | 2 ++ test/testmathlib.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index a6b63ac85..7c0071bf5 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -1280,6 +1280,8 @@ bool MathLib::isDigitSeparator(const std::string& iCode, std::string::size_type case '~': case '=': return true; + case '\'': + return isDigitSeparator(iCode, i); default: return false; } diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index d47600f9f..cf6b7f7a6 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -1145,7 +1145,7 @@ private: ASSERT_THROW(MathLib::normalizeCharacterLiteral("\\c"), InternalError); } - void CPP14DigitSeparators() { // Ticket #7137 + void CPP14DigitSeparators() { // Ticket #7137, #7565 ASSERT(MathLib::isDigitSeparator("'", 0) == false); ASSERT(MathLib::isDigitSeparator("123'0;", 3)); ASSERT(MathLib::isDigitSeparator("foo(1'2);", 5)); @@ -1160,6 +1160,7 @@ private: ASSERT(MathLib::isDigitSeparator("if (120|1'2) { char c = 'c'; }", 9)); ASSERT(MathLib::isDigitSeparator("if (120%1'2) { char c = 'c'; }", 24) == false); ASSERT(MathLib::isDigitSeparator("if (120%1'2) { char c = 'c'; }", 26) == false); + ASSERT(MathLib::isDigitSeparator("0b0000001'0010'01110", 14)); } };