From 0f8bc429adced0ec307c590b9e7bd635a99e88ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 5 Sep 2010 08:16:19 +0200 Subject: [PATCH] Fixed #2021 (false positive: syntax error with -std=gnu++0x code) --- lib/tokenize.cpp | 7 +++++++ test/testtokenize.cpp | 13 +++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7427d4826..e69ab4f0c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 419a26efd..29cedb757 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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 \n" "void fn2 (T t = []{return 1;}())\n" @@ -4172,6 +4173,14 @@ private: ASSERT_EQUALS(";\n\n\nint main ( )\n{\nfn2 ( ) ;\n}void fn2 ( int t = [ ] { return 1 ; } ( ) )\n{ }", tokenizeAndStringify(code)); } + void cpp0xtemplate2() + { + // tokenize ">>" into "> >" + const char *code = "list> ints;\n"; + ASSERT_EQUALS("list < list < int >> ints ;", tokenizeAndStringify(code)); + TODO_ASSERT_EQUALS("list < list < int > > ints ;", tokenizeAndStringify(code)); + } + void cpp0xdefault() { {