diff --git a/gcc-python-tree.c b/gcc-python-tree.c index 8daa6ed1..17833104 100644 --- a/gcc-python-tree.c +++ b/gcc-python-tree.c @@ -554,10 +554,14 @@ PyGccFunction_TypeObj_get_argument_types(struct PyGccTree * self, void *closure) } /* "size" should now be the length of the chain */ + + /* When a function with no input arguments is passed ( ex int foo()) + the previous code crashed. */ + if(size == 0) + size = 1; /* The last element in the list is a VOID_TYPE; don't add this; see dump_function_declaration() in gcc/tree-pretty-print.c */ - assert(size>0); size--; result = PyTuple_New(size); diff --git a/generate-tree-c.py b/generate-tree-c.py index 1c6df3c5..700c6f02 100644 --- a/generate-tree-c.py +++ b/generate-tree-c.py @@ -470,13 +470,29 @@ def add_complex_getter(name, doc): 'PyGccTree_New(gcc_private_make_tree(TREE_OPERAND(self->t.inner, 2)))', "The position of the first referenced bit, as a gcc.IntegerCst") - if tree_type.SYM in ('RECORD_TYPE', 'UNION_TYPE', 'QUAL_UNION_TYPE'): + if tree_type.SYM in ( 'UNION_TYPE', 'QUAL_UNION_TYPE'): add_simple_getter('fields', 'PyGcc_TreeListFromChain(TYPE_FIELDS(self->t.inner))', "The fields of this type") add_simple_getter('methods', 'PyGcc_TreeListFromChain(TYPE_METHODS(self->t.inner))', "The methods of this type") + + if tree_type.SYM in ('RECORD_TYPE'): + add_simple_getter('fields', + 'PyGcc_TreeListFromChain(TYPE_FIELDS(self->t.inner))', + "The fields of this type") + add_simple_getter('methods', + 'PyGcc_TreeListFromChain(TYPE_METHODS(self->t.inner))', + "The methods of this type") + add_simple_getter('context', + 'PyGcc_TreeListFromChain(TYPE_CONTEXT(self->t.inner))', + "The context of this type") + + if tree_type.SYM == 'ENUMERAL_TYPE': + add_simple_getter('values', + 'PyGcc_TreeListFromChain(TYPE_VALUES(self->t.inner))', + "The values of this type") if tree_type.SYM == 'IDENTIFIER_NODE': add_simple_getter('name',