pycparser icon indicating copy to clipboard operation
pycparser copied to clipboard

TypeDecl nodes of _Atomic C11 declarations have empty coord

Open ebmoll opened this issue 3 years ago • 1 comments

Nodes of type TypeDecl created by _Atomic() don't seem to have a correct coord attribute:

file atomic.c:

typedef _Atomic(char) atomic_char;
from pycparser import parse_file
from pycparser.c_ast import NodeVisitor

class TypedefVisitor(NodeVisitor):
    def visit_TypeDecl(self, node):
        print(node.coord) # prints None
        print(node.type.coord) # prints the correct location

ast = parse_file('atomic.c')
TypedefVisitor().visit(ast)

I don't know if this behavior is correct, but it seems inconsistent to me. It's a bit annoying since I use it to filter out ast nodes from included files when generating wrapper code.

ebmoll avatar Oct 04 '22 22:10 ebmoll

PRs welcome

eliben avatar Oct 04 '22 23:10 eliben