Parse auto functions with trailing return
This commit is contained in:
parent
1f5ba1b3ca
commit
e30c117b62
@ -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":
|
||||
|
@ -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",
|
||||
)
|
||||
],
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user