Support rValue references in typedef (#1823)

This commit is contained in:
PKEuS 2014-09-06 19:00:26 +02:00
parent efab840b50
commit 35b00a5e05
2 changed files with 12 additions and 1 deletions

View File

@ -687,7 +687,7 @@ void Tokenizer::simplifyTypedef()
}
// check for pointers and references
while (Token::Match(tokOffset, "*|&|const")) {
while (Token::Match(tokOffset, "*|&|&&|const")) {
pointers.push_back(tokOffset->str());
tokOffset = tokOffset->next();
}

View File

@ -304,6 +304,7 @@ private:
TEST_CASE(simplifyTypedef106); // ticket #3619
TEST_CASE(simplifyTypedef107); // ticket #3963 - bad code => segmentation fault
TEST_CASE(simplifyTypedef108); // ticket #4777
TEST_CASE(simplifyTypedef109); // ticket #1823 - rvalue reference
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -5725,6 +5726,16 @@ private:
ASSERT_EQUALS(expected, tok(code));
}
void simplifyTypedef109() {
const char code[] = "typedef int&& rref;\n"
"rref var;";
const char expected[] = "int & & var ;";
checkSimplifyTypedef(code);
ASSERT_EQUALS(expected, tok(code));
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedefFunction1() {
{
const char code[] = "typedef void (*my_func)();\n"