diff --git a/cxxheaderparser/parser.py b/cxxheaderparser/parser.py index c35707c..2be0537 100644 --- a/cxxheaderparser/parser.py +++ b/cxxheaderparser/parser.py @@ -1773,7 +1773,7 @@ class CxxParser: setattr(method, tok_value, True) elif tok_value in ("&", "&&"): method.ref_qualifier = tok_value - elif tok_value == "ARROW": + elif tok_value == "->": self._parse_trailing_return_type(method) break elif tok_value == "throw": diff --git a/tests/test_fn.py b/tests/test_fn.py index 9826012..77facfb 100644 --- a/tests/test_fn.py +++ b/tests/test_fn.py @@ -4,6 +4,8 @@ from cxxheaderparser.types import ( Array, AutoSpecifier, ClassDecl, + DecltypeSpecifier, + Field, Function, FunctionType, FundamentalSpecifier, @@ -1141,3 +1143,54 @@ def test_noexcept_contents() -> None: ] ) ) + + +def test_auto_decltype_return() -> None: + content = """ + class C { + public: + int x; + auto GetSelected() -> decltype(x); + }; + """ + data = parse_string(content, cleandoc=True) + + assert data == ParsedData( + namespace=NamespaceScope( + classes=[ + ClassScope( + class_decl=ClassDecl( + typename=PQName( + segments=[NameSpecifier(name="C")], classkey="class" + ) + ), + fields=[ + Field( + access="public", + type=Type( + typename=PQName( + segments=[FundamentalSpecifier(name="int")] + ) + ), + name="x", + ) + ], + methods=[ + Method( + return_type=Type( + typename=PQName( + segments=[ + DecltypeSpecifier(tokens=[Token(value="x")]) + ] + ) + ), + name=PQName(segments=[NameSpecifier(name="GetSelected")]), + parameters=[], + has_trailing_return=True, + access="public", + ) + ], + ) + ] + ) + )