From 015a0fdf3e89993efd4905c688f4f1de8b522cbb Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 18 Jan 2017 13:47:46 +0100 Subject: qdoc: A different way to fix the "signed" problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old qdoc parser is still used for parsing \fn commands because clang can't be used to parse code fragments. This causes a problem when the "signed" reserved word is used because clang doesn't keep it if it doesn't add anything to the type, while the old qdoc parser always appends it to the type under construction. The fix here is to let the old qdoc parser hold the "signed" reserved word aside until it knows what the next lexeme is. Then it either appends the held "signed" or discards it, depending on what the next lexeme is. e.g., if the next word is "int" discard "signed" but if the next word is "char" append the held "signed" before appending "char". Change-Id: I67953d964cd09410126d64fa3305c669111e74ce Reviewed-by: Topi Reiniƶ --- src/qdoc/cppcodeparser.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/qdoc/cppcodeparser.cpp') diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index d22cdffbb..a71c341a7 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -1099,11 +1099,24 @@ bool CppCodeParser::matchDataType(CodeChunk *dataType, QString *var, bool qProp) */ while (match(Tok_const) || match(Tok_volatile)) dataType->append(previousLexeme()); - while (match(Tok_signed) || match(Tok_unsigned) || - match(Tok_short) || match(Tok_long) || match(Tok_int64)) { - dataType->append(previousLexeme()); + QString pending; + while (tok == Tok_signed || tok == Tok_int || tok == Tok_unsigned || + tok == Tok_short || tok == Tok_long || tok == Tok_int64) { + if (tok == Tok_signed) + pending = lexeme(); + else { + if (tok == Tok_unsigned && !pending.isEmpty()) + dataType->append(pending); + pending.clear(); + dataType->append(lexeme()); + } + readToken(); virgin = false; } + if (!pending.isEmpty()) { + dataType->append(pending); + pending.clear(); + } while (match(Tok_const) || match(Tok_volatile)) dataType->append(previousLexeme()); -- cgit v1.2.1