diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 5d8a62cca..4cf68ee32 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -632,8 +632,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri // add a suppression if the next token is 'case' or 'default' if (detectFallThroughComments && fallThroughComment) { const std::string::size_type j = str.find_first_not_of("abcdefghijklmnopqrstuvwxyz", i); - const std::string tok = str.substr(i, j - i); - if (tok == "case" || tok == "default") + if (str.compare(i, j-i, "case") == 0 || str.compare(i, j-i, "default") == 0) suppressionIDs.push_back("switchCaseFallThrough"); fallThroughComment = false; } @@ -662,8 +661,12 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri } } + // C++14 digit separators + if (ch == '\'' && std::isdigit(previous)) + ; // Just skip it. + // String or char constants.. - if (ch == '\"' || ch == '\'') { + else if (ch == '\"' || ch == '\'') { code << char(ch); char chNext; do { @@ -1963,9 +1966,7 @@ void Preprocessor::error(const std::string &filename, unsigned int linenr, const { std::list locationList; if (!filename.empty()) { - ErrorLogger::ErrorMessage::FileLocation loc; - loc.line = linenr; - loc.setfile(filename); + ErrorLogger::ErrorMessage::FileLocation loc(filename, linenr); locationList.push_back(loc); } _errorLogger->reportErr(ErrorLogger::ErrorMessage(locationList, diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index dc09700e6..ce86bf414 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -67,6 +67,7 @@ private: TEST_CASE(readCode2); // #4308 - convert C++11 raw string to plain old C string TEST_CASE(readCode3); TEST_CASE(readCode4); // #4351 - escaped whitespace in gcc + TEST_CASE(readCode5); // #7042 - C++14 digit separators // reading utf-16 file TEST_CASE(utf16); @@ -336,6 +337,12 @@ private: ASSERT_EQUALS("", errout.str()); } + void readCode5() { + const char code[] = "int i = 0x1000'00;"; + ASSERT_EQUALS("int i = 0x100000;", preprocessorRead(code)); + ASSERT_EQUALS("", errout.str()); + } + void utf16() {