Skip to content

Commit 348790e

Browse files
committed
add unqualified_equivalent to gcc.Type subclasses
1 parent 36cf035 commit 348790e

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

docs/tree.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,11 @@ Additional attributes for various :py:class:`gcc.Type` subclasses:
447447
448448
The :py:class:`gcc.Type` for the `restrict` version of this type
449449

450+
.. py:attribute:: unqualified_equivalent
451+
452+
The :py:class:`gcc.Type` for the version of this type that does
453+
not have any qualifiers.
454+
450455

451456
The standard C types are accessible via class methods of :py:class:`gcc.Type`.
452457
They are only created by GCC after plugins are loaded, and so they're

generate-tree-c.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ def add_complex_getter(name, doc):
398398
add_simple_getter('%s_equivalent' % qual,
399399
'PyGccTree_New(gcc_private_make_tree(build_qualified_type(self->t.inner, TYPE_QUALS(self->t.inner) | TYPE_QUAL_%s)))' % qual.upper(),
400400
'The gcc.Type for the %s version of this type' % qual)
401+
add_simple_getter('unqualified_equivalent',
402+
'PyGccTree_New(gcc_private_make_tree(build_qualified_type(self->t.inner, 0)))',
403+
'The gcc.Type for the unqualified version of this type')
401404
if tree_type.SYM == 'RECORD_TYPE':
402405
add_simple_getter('const',
403406
'PyBool_FromLong(TYPE_READONLY(self->t.inner))',

tests/plugin/types/script.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def dump_integer_type(t):
4343
print(gcc.Type.char().const_equivalent.const)
4444
print(gcc.Type.char().const_equivalent.restrict_equivalent.const)
4545
print(gcc.Type.char().const_equivalent.volatile_equivalent.const)
46+
print(gcc.Type.char().const_equivalent.volatile_equivalent.unqualified_equivalent.const)
4647

4748
def dump_real_type(t):
4849
print('gcc.Type: %r' % str(t))

tests/plugin/types/stdout.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ False
1616
True
1717
True
1818
True
19+
False
1920
gcc.Type: 'float'
2021
t.const: False
2122
t.precision: 32

0 commit comments

Comments
 (0)