pycparserext
pycparserext copied to clipboard
Incorrect parse on struct field that is a pointer to a function with attributes that returns a function pointer
Repro:
from pycparserext.ext_c_parser import GnuCParser
repro = """
struct x {
void (*(*__attribute__((whatever)) ret_fn_ptr_attr) (void)) (void);
};
"""
p = GnuCParser()
p.parse(repro).show(attrnames=True, nodenames=True)
Expected->Actual:
FileAST:
Decl <ext[0]>: name=None, quals=[], storage=[], funcspec=[]
Struct <type>: name=x
- Decl <decls[0]>: name=ret_fn_ptr_attr, quals=[], storage=[], funcspec=[]
- PtrDecl <type>: quals=[]
+ Decl <decls[0]>: name=ret_fn_ptr_attr, quals=[], storage=[], funcspec=[]
FuncDeclExt <type>:
ParamList <args>:
Typename <params[0]>: name=None, quals=[]
TypeDecl <type>: declname=None, quals=[]
IdentifierType <type>: names=['void']
PtrDecl <type>: quals=[]
FuncDeclExt <type>:
ParamList <args>:
Typename <params[0]>: name=None, quals=[]
TypeDecl <type>: declname=None, quals=[]
IdentifierType <type>: names=['void']
TypeDeclExt <type>: declname=ret_fn_ptr_attr, quals=[]
IdentifierType <type>: names=['void']
ExprList <attributes>:
ExprList <attributes>:
- ID <exprs[0]>: name=whatever
Seen in the real world here in the emacs dynamic module interface (ultimately included in emacs_module.h here, via templating).
Thanks for the report! I'm unlikely to have time to dig into this anytime soon, but I'd be happy to look at a patch (ideally with a test).
Will look into it! It's been a while since I've poked at lex and yacc but I might be able to knock something out.
Closed by #92.