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