Skip to content

Commit 36cf035

Browse files
committed
preserve qualifiers when adding more qualifiers
Fixes #33
1 parent a16181d commit 36cf035

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

generate-tree-c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def add_complex_getter(name, doc):
396396
'PyBool_FromLong(TYPE_QUALS(self->t.inner) & TYPE_QUAL_%s)' % qual.upper(),
397397
"Boolean: does this type have the '%s' modifier?" % qual)
398398
add_simple_getter('%s_equivalent' % qual,
399-
'PyGccTree_New(gcc_private_make_tree(build_qualified_type(self->t.inner, TYPE_QUAL_%s)))' % qual.upper(),
399+
'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)
401401
if tree_type.SYM == 'RECORD_TYPE':
402402
add_simple_getter('const',

tests/plugin/types/script.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def dump_integer_type(t):
3939
dump_integer_type(gcc.Type.unsigned_char())
4040
dump_integer_type(gcc.Type.signed_char())
4141

42+
print(gcc.Type.char().const)
43+
print(gcc.Type.char().const_equivalent.const)
44+
print(gcc.Type.char().const_equivalent.restrict_equivalent.const)
45+
print(gcc.Type.char().const_equivalent.volatile_equivalent.const)
46+
4247
def dump_real_type(t):
4348
print('gcc.Type: %r' % str(t))
4449
print(' t.const: %r' % t.const)

tests/plugin/types/stdout.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ gcc.Type: 'signed char'
1212
t.min_value.constant: -128
1313
t.max_value.constant: 127
1414
t.sizeof: 1
15+
False
16+
True
17+
True
18+
True
1519
gcc.Type: 'float'
1620
t.const: False
1721
t.precision: 32

0 commit comments

Comments
 (0)