Fixed #2021 (false positive: syntax error with -std=gnu++0x code)

This commit is contained in:
Daniel Marjamäki 2010-09-05 08:16:19 +02:00
parent 7d3ccb064b
commit 0f8bc429ad
2 changed files with 18 additions and 2 deletions

View File

@ -1912,6 +1912,13 @@ bool Tokenizer::tokenize(std::istream &code,
if (level > 0)
--level;
}
else if (tok2->str() == ">>")
{
if (level > 0)
--level;
if (level > 0)
--level;
}
}
if (level > 0)
{

View File

@ -243,7 +243,8 @@ private:
TEST_CASE(removedeclspec);
TEST_CASE(removeattribute);
TEST_CASE(cpp0xtemplate);
TEST_CASE(cpp0xtemplate1);
TEST_CASE(cpp0xtemplate2);
TEST_CASE(cpp0xdefault);
TEST_CASE(arraySize);
@ -4160,7 +4161,7 @@ private:
ASSERT_EQUALS("int x [ 2 ] ;", tokenizeAndStringify("int x[2] __attribute__ ((packed));"));
}
void cpp0xtemplate()
void cpp0xtemplate1()
{
const char *code = "template <class T>\n"
"void fn2 (T t = []{return 1;}())\n"
@ -4172,6 +4173,14 @@ private:
ASSERT_EQUALS(";\n\n\nint main ( )\n{\nfn2<int> ( ) ;\n}void fn2<int> ( int t = [ ] { return 1 ; } ( ) )\n{ }", tokenizeAndStringify(code));
}
void cpp0xtemplate2()
{
// tokenize ">>" into "> >"
const char *code = "list<list<int>> ints;\n";
ASSERT_EQUALS("list < list < int >> ints ;", tokenizeAndStringify(code));
TODO_ASSERT_EQUALS("list < list < int > > ints ;", tokenizeAndStringify(code));
}
void cpp0xdefault()
{
{