summaryrefslogtreecommitdiff
path: root/tests/test_domain_c.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_domain_c.py')
-rw-r--r--tests/test_domain_c.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/test_domain_c.py b/tests/test_domain_c.py
index d59c4fc1c..0800c5059 100644
--- a/tests/test_domain_c.py
+++ b/tests/test_domain_c.py
@@ -275,6 +275,62 @@ def test_domain_c_ast_expressions():
exprCheck('a or_eq 5')
+def test_domain_c_ast_fundamental_types():
+ def types():
+ def signed(t):
+ yield t
+ yield 'signed ' + t
+ yield 'unsigned ' + t
+
+ # integer types
+ # -------------
+ yield 'void'
+ yield from ('_Bool', 'bool')
+ yield from signed('char')
+ yield from signed('short')
+ yield from signed('short int')
+ yield from signed('int')
+ yield from ('signed', 'unsigned')
+ yield from signed('long')
+ yield from signed('long int')
+ yield from signed('long long')
+ yield from signed('long long int')
+ yield from ('__int128', '__uint128')
+ # extensions
+ for t in ('__int8', '__int16', '__int32', '__int64', '__int128'):
+ yield from signed(t)
+
+ # floating point types
+ # --------------------
+ yield from ('_Decimal32', '_Decimal64', '_Decimal128')
+ for f in ('float', 'double', 'long double'):
+ yield f
+ yield from (f + " _Complex", f + " complex")
+ yield from ("_Complex " + f, "complex " + f)
+ yield from ("_Imaginary " + f, "imaginary " + f)
+ # extensions
+ # https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html#Floating-Types
+ yield from ('__float80', '_Float64x',
+ '__float128', '_Float128',
+ '__ibm128')
+ # https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html#Half-Precision
+ yield '__fp16'
+
+ # fixed-point types (extension)
+ # -----------------------------
+ # https://gcc.gnu.org/onlinedocs/gcc/Fixed-Point.html#Fixed-Point
+ for sat in ('', '_Sat '):
+ for t in ('_Fract', 'fract', '_Accum', 'accum'):
+ for size in ('short ', '', 'long ', 'long long '):
+ for tt in signed(size + t):
+ yield sat + tt
+
+ for t in types():
+ input = "{key}%s foo" % t
+ output = ' '.join(input.split())
+ check('type', input, {1: 'foo'}, key='typedef', output=output)
+
+
def test_domain_c_ast_type_definitions():
check('type', "{key}T", {1: "T"})