Summary: | C++ preprocessor parser chokes on hex numbers in parentheses | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | Alexander <ashaduri> |
Component: | Language Support: CPP (old) | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED FIXED | ||
Severity: | major | ||
Priority: | VHI | ||
Version: | git master | ||
Target Milestone: | 4.2.0 | ||
Platform: | Unlisted Binaries | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Alexander
2010-11-23 13:48:44 UTC
if possible this should be fixed for 4.2.0 commit 23c67db831373ecbed403eb885e47c61bf83a533 branch master Author: David nolden <david.nolden.kde@art-master.de> Date: Wed Jan 12 21:27:34 2011 +0100 Properly skip hexadecimal numbers in pp_skip_number. The problem is that everything starting at the "x" is pre-tokenized into one IndexedString by tokenizeFromByteArray, so we have to handle the case that the input is not a single character. BUG: 257696 diff --git a/languages/cpp/parser/rpp/pp-scanner.cpp b/languages/cpp/parser/rpp/pp-scanner.cpp index 84eb40e..e7d2576 100644 --- a/languages/cpp/parser/rpp/pp-scanner.cpp +++ b/languages/cpp/parser/rpp/pp-scanner.cpp @@ -171,7 +171,7 @@ uint pp_skip_identifier::operator()(Stream& input) void pp_skip_number::operator()(Stream& input, Stream& output) { while (!input.atEnd()) { - if (!isLetterOrNumber(input.current()) && input != '_') + if (isCharacter(input.current()) && !isLetterOrNumber(input.current()) && input != '_') return; output << input; diff --git a/languages/cpp/parser/tests/test_parser.cpp b/languages/cpp/parser/tests/test_parser.cpp index b4dddc2..2e683e4 100644 --- a/languages/cpp/parser/tests/test_parser.cpp +++ b/languages/cpp/parser/tests/test_parser.cpp @@ -449,6 +449,7 @@ private slots: QCOMPARE(preprocess("#if ~1\n#define NUMBER 10\n#else\n#define NUMBER 20\n#endif\nNUMBER").trimmed(), QString("10")); QCOMPARE(preprocess("#define MACRO(a, b) ab\nMACRO\n(aa, bb)").trimmed(), QString("ab")); QCOMPARE(preprocess("#define MACRO(a, b) ab\nMACRO(aa,\n bb)").trimmed(), QString("ab")); + QCOMPARE(preprocess("#if 0x1\n #define NUMBER 10\n#else\n#define NUMBER 20\n#endif\nNUMBER\n").trimmed(), QString("10")); } void testPreprocessorStringify() { commit a46663a1f93c6ecfbc228d69797ea25db361c6ac branch 4.2 Author: David nolden <david.nolden.kde@art-master.de> Date: Wed Jan 12 21:27:34 2011 +0100 backport from master: Properly skip hexadecimal numbers in pp_skip_number. The problem is that everything starting at the "x" is pre-tokenized into one IndexedString by tokenizeFromByteArray, so we have to handle the case that the input is not a single character. CCBUG: 257696 diff --git a/languages/cpp/parser/rpp/pp-scanner.cpp b/languages/cpp/parser/rpp/pp-scanner.cpp index 84eb40e..e7d2576 100644 --- a/languages/cpp/parser/rpp/pp-scanner.cpp +++ b/languages/cpp/parser/rpp/pp-scanner.cpp @@ -171,7 +171,7 @@ uint pp_skip_identifier::operator()(Stream& input) void pp_skip_number::operator()(Stream& input, Stream& output) { while (!input.atEnd()) { - if (!isLetterOrNumber(input.current()) && input != '_') + if (isCharacter(input.current()) && !isLetterOrNumber(input.current()) && input != '_') return; output << input; diff --git a/languages/cpp/parser/tests/test_parser.cpp b/languages/cpp/parser/tests/test_parser.cpp index b4dddc2..2e683e4 100644 --- a/languages/cpp/parser/tests/test_parser.cpp +++ b/languages/cpp/parser/tests/test_parser.cpp @@ -449,6 +449,7 @@ private slots: QCOMPARE(preprocess("#if ~1\n#define NUMBER 10\n#else\n#define NUMBER 20\n#endif\nNUMBER").trimmed(), QString("10")); QCOMPARE(preprocess("#define MACRO(a, b) ab\nMACRO\n(aa, bb)").trimmed(), QString("ab")); QCOMPARE(preprocess("#define MACRO(a, b) ab\nMACRO(aa,\n bb)").trimmed(), QString("ab")); + QCOMPARE(preprocess("#if 0x1\n #define NUMBER 10\n#else\n#define NUMBER 20\n#endif\nNUMBER\n").trimmed(), QString("10")); } void testPreprocessorStringify() { Moving all the bugs from the CPP Parser. It was not well defined the difference between it and C++ Language Support and people kept reporting in both places indistinctively |