Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion cxxheaderparser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,12 +1188,61 @@ def _parse_using_typealias(

mods.validate(var_ok=False, meth_ok=False, msg="parsing typealias")

dtype = self._parse_cv_ptr(parsed_type)
if parsed_type.typename.classkey in ("class", "struct", "union"):
tok = self.lex.token_if_in_set(self._class_enum_stage2)
if tok:
self._parse_class_decl(
parsed_type.typename,
tok,
doxygen,
template,
False,
tok.location,
mods,
[],
)
self._parse_typealias_class_body()

dtype = self._parse_cv_ptr_or_fn(parsed_type, nonptr_fn=True)

tok = self.lex.token_if("[")
while tok:
if isinstance(dtype, FunctionType):
raise CxxParseError("arrays of functions are illegal", tok)
dtype = self._parse_array_type(tok, dtype)
tok = self.lex.token_if("[")

alias = UsingAlias(id_tok.value, dtype, template, self._current_access, doxygen)

self.visitor.on_using_alias(self.state, alias)

def _parse_typealias_class_body(self) -> None:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular, this seems wrong.

class_state = self.state

while self.state is not class_state.parent:
doxygen = self.lex.get_doxygen()
tok = self.lex.token()

if tok.type == "}":
if self.state is class_state:
self._pop_state()
else:
self._on_block_end(tok, doxygen)
elif tok.type in ("private", "protected", "public"):
self._process_access_specifier(tok, doxygen)
elif tok.type == "template":
self._parse_template(tok, doxygen)
elif tok.type == "typedef":
self._parse_typedef(tok, doxygen)
elif tok.type == "using":
self._parse_using(tok, doxygen)
elif tok.type == "static_assert":
self._consume_static_assert(tok, doxygen)
elif tok.type == ";":
pass
else:
self._parse_declarations(tok, doxygen)

def _parse_using(
self,
tok: LexToken,
Expand Down
2 changes: 1 addition & 1 deletion cxxheaderparser/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ class UsingAlias:
"""

alias: str
type: DecoratedType
type: typing.Union[DecoratedType, FunctionType]

template: typing.Optional[TemplateDecl] = None

Expand Down
Loading
Loading