Skip to content

Commit

Permalink
Fix bug for classes that have an export macro and are final at the sa…
Browse files Browse the repository at this point in the history
…me time (myint#152)
  • Loading branch information
Niederb authored and myint committed Nov 10, 2019
1 parent 8340aba commit aa73d06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cpp/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit aa73d06

Please sign in to comment.