From 369b1f7f38ab81ba216e03fc724925db8f1b11ed Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Wed, 30 Dec 2015 16:47:12 +0100 Subject: [PATCH] Lexer: Support Microsoft suffix (u)i64 MSVC2010 supports all combinations of upper- and lowercase U/I. Task-number: QTCREATORBUG-15554 Change-Id: I0106e6b5038a62aebe5a6c1eb0467d693befb4b0 Reviewed-by: Nikolai Kosjar --- src/libs/3rdparty/cplusplus/Lexer.cpp | 11 +++++++++++ tests/auto/cplusplus/lexer/tst_lexer.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/libs/3rdparty/cplusplus/Lexer.cpp b/src/libs/3rdparty/cplusplus/Lexer.cpp index ac0b4a7ed60..db7cb9e0f83 100644 --- a/src/libs/3rdparty/cplusplus/Lexer.cpp +++ b/src/libs/3rdparty/cplusplus/Lexer.cpp @@ -853,6 +853,17 @@ bool Lexer::scanOptionalIntegerSuffix(bool allowU) scanOptionalIntegerSuffix(false); } return true; + case 'i': + case 'I': + yyinp(); + if (_yychar == '6') { + yyinp(); + if (_yychar == '4') { + yyinp(); + return true; + } + } + return false; case 'l': yyinp(); if (_yychar == 'l') diff --git a/tests/auto/cplusplus/lexer/tst_lexer.cpp b/tests/auto/cplusplus/lexer/tst_lexer.cpp index fc2b8da0476..ee4cd0499c4 100644 --- a/tests/auto/cplusplus/lexer/tst_lexer.cpp +++ b/tests/auto/cplusplus/lexer/tst_lexer.cpp @@ -336,6 +336,30 @@ void tst_SimpleLexer::literals_data() ; QTest::newRow("integer-literals") << source << expectedTokenKindList; + source = + "42ui64\n" + "43UI64\n" + "44Ui64\n" + "45uI64\n" + "46i64\n" + "47I64\n" + "0xffffui64\n" + "0xfffeUi64\n" + "0xfffdi64\n" + "56ui\n" // incomplete + "56ui6\n" + "57ui67\n" // wrong + "58i67\n" + ; + expectedTokenKindList = + TokenKindList() << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL + << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL + << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL + << T_NUMERIC_LITERAL << T_NUMERIC_LITERAL + << T_ERROR << T_ERROR + ; + QTest::newRow("microsoft-suffix") << source << expectedTokenKindList; + source = "R\"(raw text)\"\n" "R\"delimiter(raw text)delimiter\"\n"