moc: handle "L" integer suffix
This commit adds some initial support for handling the 'L' suffix after numbers. This one is especially important given that the __cplusplus define is using it. Other suffixes will be handled in some later commit, which should also unify the already divergent parse behavior between DIGIT and PP_DIGIT parsing (e.g. when it comes to byte prefixes). Task-number: QTBUG-83160 Task-number: QTBUG-115558 Change-Id: Ie61eae49c468abfaee80e7e4f7097917a254dc0e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit f0039bd5170ad84d972a023316e8d153b89f841a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9758650a37
commit
8ac712968a
@ -223,7 +223,8 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso
|
|||||||
++data;
|
++data;
|
||||||
while (is_hex_char(*data) || *data == '\'')
|
while (is_hex_char(*data) || *data == '\'')
|
||||||
++data;
|
++data;
|
||||||
}
|
} else if (*data == 'L') // TODO: handle other suffixes
|
||||||
|
++data;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
token = FLOATING_LITERAL;
|
token = FLOATING_LITERAL;
|
||||||
@ -400,7 +401,8 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso
|
|||||||
++data;
|
++data;
|
||||||
while (is_hex_char(*data) || *data == '\'')
|
while (is_hex_char(*data) || *data == '\'')
|
||||||
++data;
|
++data;
|
||||||
}
|
} else if (*data == 'L') // TODO: handle other suffixes
|
||||||
|
++data;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
token = PP_FLOATING_LITERAL;
|
token = PP_FLOATING_LITERAL;
|
||||||
@ -930,7 +932,11 @@ int PP_Expression::primary_expression()
|
|||||||
test(PP_RPAREN);
|
test(PP_RPAREN);
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
value = lexem().toInt(nullptr, 0);
|
const QByteArray &lex = lexem();
|
||||||
|
auto lexView = QByteArrayView(lex);
|
||||||
|
if (lex.endsWith('L'))
|
||||||
|
lexView.chop(1);
|
||||||
|
value = lexView.toInt(nullptr, 0);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -617,6 +617,10 @@ private slots:
|
|||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
|
// quick test to verify that moc handles the L suffix
|
||||||
|
// correctly in the preprocessor
|
||||||
|
#if 2000L < 1
|
||||||
|
#else
|
||||||
class PropertyTestClass : public QObject
|
class PropertyTestClass : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -626,6 +630,7 @@ public:
|
|||||||
|
|
||||||
Q_ENUM(TestEnum)
|
Q_ENUM(TestEnum)
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
class PropertyUseClass : public QObject
|
class PropertyUseClass : public QObject
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user