| ... | ... | @@ -891,42 +891,39 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void { |
| 891 | 891 | \\} |
| 892 | 892 | , ""); |
| 893 | 893 | |
| 894 | | if (@import("builtin").zig_backend == .stage1) { |
| 895 | | // https://github.com/ziglang/zig/issues/12263 |
| 896 | | cases.add("Obscure ways of calling functions; issue #4124", |
| 897 | | \\#include <stdlib.h> |
| 898 | | \\static int add(int a, int b) { |
| 899 | | \\ return a + b; |
| 900 | | \\} |
| 901 | | \\typedef int (*adder)(int, int); |
| 902 | | \\typedef void (*funcptr)(void); |
| 903 | | \\int main() { |
| 904 | | \\ if ((add)(1, 2) != 3) abort(); |
| 905 | | \\ if ((&add)(1, 2) != 3) abort(); |
| 906 | | \\ if (add(3, 1) != 4) abort(); |
| 907 | | \\ if ((*add)(2, 3) != 5) abort(); |
| 908 | | \\ if ((**add)(7, -1) != 6) abort(); |
| 909 | | \\ if ((***add)(-2, 9) != 7) abort(); |
| 910 | | \\ |
| 911 | | \\ int (*ptr)(int a, int b); |
| 912 | | \\ ptr = add; |
| 913 | | \\ |
| 914 | | \\ if (ptr(1, 2) != 3) abort(); |
| 915 | | \\ if ((*ptr)(3, 1) != 4) abort(); |
| 916 | | \\ if ((**ptr)(2, 3) != 5) abort(); |
| 917 | | \\ if ((***ptr)(7, -1) != 6) abort(); |
| 918 | | \\ if ((****ptr)(-2, 9) != 7) abort(); |
| 919 | | \\ |
| 920 | | \\ funcptr addr1 = (funcptr)(add); |
| 921 | | \\ funcptr addr2 = (funcptr)(&add); |
| 922 | | \\ |
| 923 | | \\ if (addr1 != addr2) abort(); |
| 924 | | \\ if (((int(*)(int, int))addr1)(1, 2) != 3) abort(); |
| 925 | | \\ if (((adder)addr2)(1, 2) != 3) abort(); |
| 926 | | \\ return 0; |
| 927 | | \\} |
| 928 | | , ""); |
| 929 | | } |
| 894 | cases.add("Obscure ways of calling functions; issue #4124", |
| 895 | \\#include <stdlib.h> |
| 896 | \\static int add(int a, int b) { |
| 897 | \\ return a + b; |
| 898 | \\} |
| 899 | \\typedef int (*adder)(int, int); |
| 900 | \\typedef void (*funcptr)(void); |
| 901 | \\int main() { |
| 902 | \\ if ((add)(1, 2) != 3) abort(); |
| 903 | \\ if ((&add)(1, 2) != 3) abort(); |
| 904 | \\ if (add(3, 1) != 4) abort(); |
| 905 | \\ if ((*add)(2, 3) != 5) abort(); |
| 906 | \\ if ((**add)(7, -1) != 6) abort(); |
| 907 | \\ if ((***add)(-2, 9) != 7) abort(); |
| 908 | \\ |
| 909 | \\ int (*ptr)(int a, int b); |
| 910 | \\ ptr = add; |
| 911 | \\ |
| 912 | \\ if (ptr(1, 2) != 3) abort(); |
| 913 | \\ if ((*ptr)(3, 1) != 4) abort(); |
| 914 | \\ if ((**ptr)(2, 3) != 5) abort(); |
| 915 | \\ if ((***ptr)(7, -1) != 6) abort(); |
| 916 | \\ if ((****ptr)(-2, 9) != 7) abort(); |
| 917 | \\ |
| 918 | \\ funcptr addr1 = (funcptr)(add); |
| 919 | \\ funcptr addr2 = (funcptr)(&add); |
| 920 | \\ |
| 921 | \\ if (addr1 != addr2) abort(); |
| 922 | \\ if (((int(*)(int, int))addr1)(1, 2) != 3) abort(); |
| 923 | \\ if (((adder)addr2)(1, 2) != 3) abort(); |
| 924 | \\ return 0; |
| 925 | \\} |
| 926 | , ""); |
| 930 | 927 | |
| 931 | 928 | cases.add("Return boolean expression as int; issue #6215", |
| 932 | 929 | \\#include <stdlib.h> |