| ... | @@ -891,39 +891,42 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void { | ... | @@ -891,39 +891,42 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void { |
| 891 | \\} | 891 | \\} |
| 892 | , ""); | 892 | , ""); |
| 893 | | 893 | |
| 894 | cases.add("Obscure ways of calling functions; issue #4124", | 894 | if (@import("builtin").zig_backend == .stage1) { |
| 895 | \\#include <stdlib.h> | 895 | // https://github.com/ziglang/zig/issues/12263 |
| 896 | \\static int add(int a, int b) { | 896 | cases.add("Obscure ways of calling functions; issue #4124", |
| 897 | \\ return a + b; | 897 | \\#include <stdlib.h> |
| 898 | \\} | 898 | \\static int add(int a, int b) { |
| 899 | \\typedef int (*adder)(int, int); | 899 | \\ return a + b; |
| 900 | \\typedef void (*funcptr)(void); | 900 | \\} |
| 901 | \\int main() { | 901 | \\typedef int (*adder)(int, int); |
| 902 | \\ if ((add)(1, 2) != 3) abort(); | 902 | \\typedef void (*funcptr)(void); |
| 903 | \\ if ((&add)(1, 2) != 3) abort(); | 903 | \\int main() { |
| 904 | \\ if (add(3, 1) != 4) abort(); | 904 | \\ if ((add)(1, 2) != 3) abort(); |
| 905 | \\ if ((*add)(2, 3) != 5) abort(); | 905 | \\ if ((&add)(1, 2) != 3) abort(); |
| 906 | \\ if ((**add)(7, -1) != 6) abort(); | 906 | \\ if (add(3, 1) != 4) abort(); |
| 907 | \\ if ((***add)(-2, 9) != 7) abort(); | 907 | \\ if ((*add)(2, 3) != 5) abort(); |
| 908 | \\ | 908 | \\ if ((**add)(7, -1) != 6) abort(); |
| 909 | \\ int (*ptr)(int a, int b); | 909 | \\ if ((***add)(-2, 9) != 7) abort(); |
| 910 | \\ ptr = add; | 910 | \\ |
| 911 | \\ | 911 | \\ int (*ptr)(int a, int b); |
| 912 | \\ if (ptr(1, 2) != 3) abort(); | 912 | \\ ptr = add; |
| 913 | \\ if ((*ptr)(3, 1) != 4) abort(); | 913 | \\ |
| 914 | \\ if ((**ptr)(2, 3) != 5) abort(); | 914 | \\ if (ptr(1, 2) != 3) abort(); |
| 915 | \\ if ((***ptr)(7, -1) != 6) abort(); | 915 | \\ if ((*ptr)(3, 1) != 4) abort(); |
| 916 | \\ if ((****ptr)(-2, 9) != 7) abort(); | 916 | \\ if ((**ptr)(2, 3) != 5) abort(); |
| 917 | \\ | 917 | \\ if ((***ptr)(7, -1) != 6) abort(); |
| 918 | \\ funcptr addr1 = (funcptr)(add); | 918 | \\ if ((****ptr)(-2, 9) != 7) abort(); |
| 919 | \\ funcptr addr2 = (funcptr)(&add); | 919 | \\ |
| 920 | \\ | 920 | \\ funcptr addr1 = (funcptr)(add); |
| 921 | \\ if (addr1 != addr2) abort(); | 921 | \\ funcptr addr2 = (funcptr)(&add); |
| 922 | \\ if (((int(*)(int, int))addr1)(1, 2) != 3) abort(); | 922 | \\ |
| 923 | \\ if (((adder)addr2)(1, 2) != 3) abort(); | 923 | \\ if (addr1 != addr2) abort(); |
| 924 | \\ return 0; | 924 | \\ if (((int(*)(int, int))addr1)(1, 2) != 3) abort(); |
| 925 | \\} | 925 | \\ if (((adder)addr2)(1, 2) != 3) abort(); |
| 926 | , ""); | 926 | \\ return 0; |
| | 927 | \\} |
| | 928 | , ""); |
| | 929 | } |
| 927 | | 930 | |
| 928 | cases.add("Return boolean expression as int; issue #6215", | 931 | cases.add("Return boolean expression as int; issue #6215", |
| 929 | \\#include <stdlib.h> | 932 | \\#include <stdlib.h> |
| ... | @@ -1319,25 +1322,28 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void { | ... | @@ -1319,25 +1322,28 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void { |
| 1319 | \\} | 1322 | \\} |
| 1320 | , ""); | 1323 | , ""); |
| 1321 | | 1324 | |
| 1322 | cases.add("basic vector expressions", | 1325 | if (@import("builtin").zig_backend == .stage1) { |
| 1323 | \\#include <stdlib.h> | 1326 | // https://github.com/ziglang/zig/issues/12264 |
| 1324 | \\#include <stdint.h> | 1327 | cases.add("basic vector expressions", |
| 1325 | \\typedef int16_t __v8hi __attribute__((__vector_size__(16))); | 1328 | \\#include <stdlib.h> |
| 1326 | \\int main(int argc, char**argv) { | 1329 | \\#include <stdint.h> |
| 1327 | \\ __v8hi uninitialized; | 1330 | \\typedef int16_t __v8hi __attribute__((__vector_size__(16))); |
| 1328 | \\ __v8hi empty_init = {}; | 1331 | \\int main(int argc, char**argv) { |
| 1329 | \\ __v8hi partial_init = {0, 1, 2, 3}; | 1332 | \\ __v8hi uninitialized; |
| 1330 | \\ | 1333 | \\ __v8hi empty_init = {}; |
| 1331 | \\ __v8hi a = {0, 1, 2, 3, 4, 5, 6, 7}; | 1334 | \\ __v8hi partial_init = {0, 1, 2, 3}; |
| 1332 | \\ __v8hi b = (__v8hi) {100, 200, 300, 400, 500, 600, 700, 800}; | 1335 | \\ |
| 1333 | \\ | 1336 | \\ __v8hi a = {0, 1, 2, 3, 4, 5, 6, 7}; |
| 1334 | \\ __v8hi sum = a + b; | 1337 | \\ __v8hi b = (__v8hi) {100, 200, 300, 400, 500, 600, 700, 800}; |
| 1335 | \\ for (int i = 0; i < 8; i++) { | 1338 | \\ |
| 1336 | \\ if (sum[i] != a[i] + b[i]) abort(); | 1339 | \\ __v8hi sum = a + b; |
| 1337 | \\ } | 1340 | \\ for (int i = 0; i < 8; i++) { |
| 1338 | \\ return 0; | 1341 | \\ if (sum[i] != a[i] + b[i]) abort(); |
| 1339 | \\} | 1342 | \\ } |
| 1340 | , ""); | 1343 | \\ return 0; |
| | 1344 | \\} |
| | 1345 | , ""); |
| | 1346 | } |
| 1341 | | 1347 | |
| 1342 | cases.add("__builtin_shufflevector", | 1348 | cases.add("__builtin_shufflevector", |
| 1343 | \\#include <stdlib.h> | 1349 | \\#include <stdlib.h> |