aboutsummaryrefslogtreecommitdiff
path: root/tests/tests2/94_generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tests2/94_generic.c')
-rw-r--r--tests/tests2/94_generic.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/tests2/94_generic.c b/tests/tests2/94_generic.c
index fad028b..4f989f0 100644
--- a/tests/tests2/94_generic.c
+++ b/tests/tests2/94_generic.c
@@ -20,6 +20,8 @@ int b_f()
return 10;
}
+typedef int int_type1;
+
#define gen_sw(a) _Generic(a, const char *: 1, default: 8, int: 123);
int main()
@@ -28,24 +30,32 @@ int main()
struct b titi;
const int * const ptr;
const char *ti;
+ int_type1 i2;
i = _Generic(a, int: a_f, const int: b_f)();
printf("%d\n", i);
+ i = _Generic(a, int: a_f() / 2, const int: b_f() / 2);
+ printf("%d\n", i);
i = _Generic(ptr, int *:1, int * const:2, default:20);
printf("%d\n", i);
i = gen_sw(a);
printf("%d\n", i);
i = _Generic(titi, struct a:1, struct b:2, default:20);
printf("%d\n", i);
+ i = _Generic(i2, char: 1, int : 0);
+ printf("%d\n", i);
i = _Generic(a, char:1, int[4]:2, default:5);
printf("%d\n", i);
i = _Generic(17, int :1, int **:2);
printf("%d\n", i);
- i = _Generic(17L, int :1, long :2);
+ i = _Generic(17L, int :1, long :2, long long : 3);
printf("%d\n", i);
- i = _Generic("17, io", const char *:1, char *:3, const int :2);
+ i = _Generic("17, io", char *: 3, const char *: 1);
printf("%d\n", i);
- i = _Generic(ti, const char *:1, char *:3, const int :2);
+ i = _Generic(ti, const unsigned char *:1, const char *:4, char *:3,
+ const signed char *:2);
printf("%d\n", i);
+ printf("%s\n", _Generic(i + 2L, long: "long", int: "int",
+ long long: "long long"));
return 0;
}