From b7ad2fe69c68d9d8ab05aceccb9b0aeb7e9a2c15 Mon Sep 17 00:00:00 2001 From: Renaud Durlin Date: Wed, 15 Jul 2015 23:18:18 +0200 Subject: [PATCH] Fix parsing of friend with double colon --- cpp/ast.py | 2 ++ test/expected.txt | 8 ++++---- test/foo.h | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cpp/ast.py b/cpp/ast.py index b348851..5ea0ee3 100644 --- a/cpp/ast.py +++ b/cpp/ast.py @@ -1378,6 +1378,8 @@ def handle_friend(self): tokens.append(last) self._add_back_tokens(tokens) token = self._get_next_token() + if token.name == '::': + token = self._get_next_token() result = self._generate_one(token) else: if tokens[0].name == 'class': diff --git a/test/expected.txt b/test/expected.txt index 580c7a3..6c601a7 100644 --- a/test/expected.txt +++ b/test/expected.txt @@ -16,10 +16,10 @@ test/foo.h:101: static data 'ptof' test/foo.h:106: static data 'data' test/foo.h:208: static data 'garbage_state' test/foo.h:225: static data 'flags_' -test/foo.h:239: static data 'foo' -test/foo.h:241: static data 'GlobalKey' -test/foo.h:268: static data 'Singleton::instance_' -test/foo.h:274: static data 'string_list' +test/foo.h:240: static data 'foo' +test/foo.h:242: static data 'GlobalKey' +test/foo.h:269: static data 'Singleton::instance_' +test/foo.h:275: static data 'string_list' test/include.h:1: 'empty.cc' does not need to be #included test/include.h:1: should not #include C++ source file 'empty.cc' test/include.h:3: 'include.h' #includes itself diff --git a/test/foo.h b/test/foo.h index 887ff4e..a0e8f4e 100644 --- a/test/foo.h +++ b/test/foo.h @@ -234,6 +234,7 @@ class MyF { class Colon { virtual ::Foo GetFoo(); ::Foo GetFoo2(); + friend ::Foo& fn(); }; string foo = "\nX=\"/*\"";