From aa73d06022533a3ff0a956910f2df9a54c233d88 Mon Sep 17 00:00:00 2001 From: Thomas Niederberger <781000+Niederb@users.noreply.github.com> Date: Sun, 10 Nov 2019 17:15:47 +0100 Subject: [PATCH] Fix bug for classes that have an export macro and are final at the same time (#152) --- cpp/ast.py | 3 +++ test_ast.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/cpp/ast.py b/cpp/ast.py index b56936b..1fbdc30 100644 --- a/cpp/ast.py +++ b/cpp/ast.py @@ -1521,6 +1521,9 @@ def _get_class(self, class_type, templated_types): assert_parse(class_name, class_token) bases = None + + if token.name == 'final': + token = self._get_next_token() if token.token_type == tokenize.PREPROCESSOR: token = self._get_next_token() if token.token_type == tokenize.SYNTAX: diff --git a/test_ast.py b/test_ast.py index 541c07f..faa33b8 100755 --- a/test_ast.py +++ b/test_ast.py @@ -896,6 +896,12 @@ def test_class_virtual_inheritance_reverse(self): self.assertEqual(1, len(nodes), repr(nodes)) self.assertEqual(Class('Foo', bases=[Type('Bar')], body=[]), nodes[0]) + def test_class_macro_final(self): + code = 'class EXPORT_MACRO Foo final {};' + nodes = list(MakeBuilder(code).generate()) + self.assertEqual(1, len(nodes), repr(nodes)) + self.assertEqual(Class('Foo', body=[]), nodes[0]) + def test_constructor(self): code = 'Foo::Foo() {}' nodes = list(MakeBuilder(code).generate())