moc: Fix parsing of digit separator

[ChangeLog][moc] Fixed parsing errors in presence of
C++14 digit separators.

Task-number: QTBUG-59351
Change-Id: Iea38ea7388853d84b819c2beb78a59371f57bf7d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Olivier Goffart 2017-03-08 13:14:59 +01:00 committed by Olivier Goffart (Woboq GmbH)
parent b53d7664c9
commit 11d60dcad6
2 changed files with 12 additions and 8 deletions

View File

@ -236,7 +236,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso
data -= 2; data -= 2;
break; break;
case DIGIT: case DIGIT:
while (is_digit_char(*data)) while (is_digit_char(*data) || *data == '\'')
++data; ++data;
if (!*data || *data != '.') { if (!*data || *data != '.') {
token = INTEGER_LITERAL; token = INTEGER_LITERAL;
@ -244,7 +244,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso
(*data == 'x' || *data == 'X') (*data == 'x' || *data == 'X')
&& *lexem == '0') { && *lexem == '0') {
++data; ++data;
while (is_hex_char(*data)) while (is_hex_char(*data) || *data == '\'')
++data; ++data;
} }
break; break;
@ -253,13 +253,13 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso
++data; ++data;
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case FLOATING_LITERAL: case FLOATING_LITERAL:
while (is_digit_char(*data)) while (is_digit_char(*data) || *data == '\'')
++data; ++data;
if (*data == '+' || *data == '-') if (*data == '+' || *data == '-')
++data; ++data;
if (*data == 'e' || *data == 'E') { if (*data == 'e' || *data == 'E') {
++data; ++data;
while (is_digit_char(*data)) while (is_digit_char(*data) || *data == '\'')
++data; ++data;
} }
if (*data == 'f' || *data == 'F' if (*data == 'f' || *data == 'F'
@ -413,7 +413,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso
token = PP_CHARACTER_LITERAL; token = PP_CHARACTER_LITERAL;
break; break;
case PP_DIGIT: case PP_DIGIT:
while (is_digit_char(*data)) while (is_digit_char(*data) || *data == '\'')
++data; ++data;
if (!*data || *data != '.') { if (!*data || *data != '.') {
token = PP_INTEGER_LITERAL; token = PP_INTEGER_LITERAL;
@ -421,7 +421,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso
(*data == 'x' || *data == 'X') (*data == 'x' || *data == 'X')
&& *lexem == '0') { && *lexem == '0') {
++data; ++data;
while (is_hex_char(*data)) while (is_hex_char(*data) || *data == '\'')
++data; ++data;
} }
break; break;
@ -430,13 +430,13 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso
++data; ++data;
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case PP_FLOATING_LITERAL: case PP_FLOATING_LITERAL:
while (is_digit_char(*data)) while (is_digit_char(*data) || *data == '\'')
++data; ++data;
if (*data == '+' || *data == '-') if (*data == '+' || *data == '-')
++data; ++data;
if (*data == 'e' || *data == 'E') { if (*data == 'e' || *data == 'E') {
++data; ++data;
while (is_digit_char(*data)) while (is_digit_char(*data) || *data == '\'')
++data; ++data;
} }
if (*data == 'f' || *data == 'F' if (*data == 'f' || *data == 'F'

View File

@ -521,6 +521,10 @@ public slots:
private: private:
myNS::Points m_points; myNS::Points m_points;
#ifdef Q_MOC_RUN
int xx = 11'11; // digit separator must not confuse moc (QTBUG-59351)
#endif
private slots: private slots:
inline virtual void blub1() {} inline virtual void blub1() {}
virtual inline void blub2() {} virtual inline void blub2() {}