Skip to content

Commit a4f579c

Browse files
eqvinoxdavidmalcolm
authored andcommitted
tests: exercise gcc.TypeDecl.original_type
1 parent 8d7b210 commit a4f579c

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

tests/plugin/types/input.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@
1717
<http://www.gnu.org/licenses/>.
1818
*/
1919

20+
typedef int mytype;
21+
typedef mytype nestedtype;

tests/plugin/types/script.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,18 @@ def dump_real_type(t):
5555
dump_real_type(gcc.Type.float())
5656
dump_real_type(gcc.Type.double())
5757

58+
def dump_typedef(td):
59+
t = td.type
60+
print('gcc.TypeDecl: %r' % str(td))
61+
print(' td.original_type: %r' % td.original_type)
62+
print(' td.original_type is gcc.Type.int(): %r' % (td.original_type is gcc.Type.int()))
63+
mytype = gccutils.get_global_typedef('mytype')
64+
print(' td.original_type.name: %r' % td.original_type.name)
65+
print(' td.original_type.name is mytype: %r' % (td.original_type.name is mytype))
66+
dump_integer_type(t)
67+
68+
dump_typedef(gccutils.get_global_typedef('mytype'))
69+
dump_typedef(gccutils.get_global_typedef('nestedtype'))
70+
5871
gcc.register_callback(gcc.PLUGIN_FINISH_UNIT,
5972
on_finish_unit)

tests/plugin/types/stdout.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,27 @@ gcc.Type: 'double'
2525
t.const: False
2626
t.precision: 64
2727
t.sizeof: 8
28+
gcc.TypeDecl: 'mytype'
29+
td.original_type: gcc.IntegerType(name=gcc.TypeDecl('int'))
30+
td.original_type is gcc.Type.int(): True
31+
td.original_type.name: gcc.TypeDecl('int')
32+
td.original_type.name is mytype: False
33+
gcc.Type: 'mytype'
34+
t.const: False
35+
t.unsigned: False
36+
t.precision: 32
37+
t.min_value.constant: -2147483648
38+
t.max_value.constant: 2147483647
39+
t.sizeof: 4
40+
gcc.TypeDecl: 'nestedtype'
41+
td.original_type: gcc.IntegerType(name=gcc.TypeDecl('mytype'))
42+
td.original_type is gcc.Type.int(): False
43+
td.original_type.name: gcc.TypeDecl('mytype')
44+
td.original_type.name is mytype: True
45+
gcc.Type: 'nestedtype'
46+
t.const: False
47+
t.unsigned: False
48+
t.precision: 32
49+
t.min_value.constant: -2147483648
50+
t.max_value.constant: 2147483647
51+
t.sizeof: 4

0 commit comments

Comments
 (0)