Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1708bf9b8 | ||
|
|
cafb594179 | ||
|
|
0e732f1d43 | ||
|
|
42bc6b60ad |
@@ -1914,11 +1914,12 @@ class CxxParser:
|
||||
fn_template = fn_template[0]
|
||||
fn_template.raw_requires_post = self._parse_requires(rtok)
|
||||
|
||||
if self.lex.token_if("ARROW"):
|
||||
self._parse_trailing_return_type(fn)
|
||||
|
||||
if self.lex.token_if("{"):
|
||||
self._discard_contents("{", "}")
|
||||
fn.has_body = True
|
||||
elif self.lex.token_if("ARROW"):
|
||||
self._parse_trailing_return_type(fn)
|
||||
|
||||
def _parse_method_end(self, method: Method) -> None:
|
||||
"""
|
||||
@@ -1963,6 +1964,9 @@ class CxxParser:
|
||||
method.ref_qualifier = tok_value
|
||||
elif tok_value == "->":
|
||||
self._parse_trailing_return_type(method)
|
||||
if self.lex.token_if("{"):
|
||||
self._discard_contents("{", "}")
|
||||
method.has_body = True
|
||||
break
|
||||
elif tok_value == "throw":
|
||||
tok = self._next_token_must_be("(")
|
||||
|
||||
@@ -848,6 +848,7 @@ class Field:
|
||||
constexpr: bool = False
|
||||
mutable: bool = False
|
||||
static: bool = False
|
||||
inline: bool = False
|
||||
|
||||
doxygen: typing.Optional[str] = None
|
||||
|
||||
|
||||
@@ -3336,3 +3336,40 @@ def test_constructor_outside_class() -> None:
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_class_inline_static() -> None:
|
||||
content = """
|
||||
struct X {
|
||||
inline static bool Foo = 1;
|
||||
};
|
||||
"""
|
||||
data = parse_string(content, cleandoc=True)
|
||||
|
||||
assert data == ParsedData(
|
||||
namespace=NamespaceScope(
|
||||
classes=[
|
||||
ClassScope(
|
||||
class_decl=ClassDecl(
|
||||
typename=PQName(
|
||||
segments=[NameSpecifier(name="X")], classkey="struct"
|
||||
)
|
||||
),
|
||||
fields=[
|
||||
Field(
|
||||
access="public",
|
||||
type=Type(
|
||||
typename=PQName(
|
||||
segments=[FundamentalSpecifier(name="bool")]
|
||||
)
|
||||
),
|
||||
name="Foo",
|
||||
value=Value(tokens=[Token(value="1")]),
|
||||
static=True,
|
||||
inline=True,
|
||||
)
|
||||
],
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1194,3 +1194,67 @@ def test_auto_decltype_return() -> None:
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_fn_trailing_return_with_body() -> None:
|
||||
content = """
|
||||
auto test() -> void
|
||||
{
|
||||
}
|
||||
"""
|
||||
data = parse_string(content, cleandoc=True)
|
||||
|
||||
assert data == ParsedData(
|
||||
namespace=NamespaceScope(
|
||||
functions=[
|
||||
Function(
|
||||
return_type=Type(
|
||||
typename=PQName(segments=[FundamentalSpecifier(name="void")])
|
||||
),
|
||||
name=PQName(segments=[NameSpecifier(name="test")]),
|
||||
parameters=[],
|
||||
has_body=True,
|
||||
has_trailing_return=True,
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_method_trailing_return_with_body() -> None:
|
||||
content = """
|
||||
struct X {
|
||||
auto test() -> void
|
||||
{
|
||||
}
|
||||
};
|
||||
"""
|
||||
data = parse_string(content, cleandoc=True)
|
||||
|
||||
assert data == ParsedData(
|
||||
namespace=NamespaceScope(
|
||||
classes=[
|
||||
ClassScope(
|
||||
class_decl=ClassDecl(
|
||||
typename=PQName(
|
||||
segments=[NameSpecifier(name="X")], classkey="struct"
|
||||
)
|
||||
),
|
||||
methods=[
|
||||
Method(
|
||||
return_type=Type(
|
||||
typename=PQName(
|
||||
segments=[FundamentalSpecifier(name="void")]
|
||||
)
|
||||
),
|
||||
name=PQName(segments=[NameSpecifier(name="test")]),
|
||||
parameters=[],
|
||||
has_body=True,
|
||||
has_trailing_return=True,
|
||||
access="public",
|
||||
)
|
||||
],
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user