History

sizeof/alignof/typeof tests

bellard committed 24 years ago

Commit b31d34f1 parent b8772fc1 file · +67 −7Browse files

Unified · Split

tcctest.c+67−7
@@ -60,6 +60,9 @@ void longlong_test(void); · 59 unmodified lines
6060 void stdarg_test(void);
6161 void whitespace_test(void);
6262 void relocation_test(void);
63+void old_style_function(void);
64+void sizeof_test(void);
65+void typeof_test(void);
6366
6467 int fib(int n);
6568 void num(int n);
@@ -192,7 +195,7 @@ void macro_test(void) · 126 unmodified lines
192195 #line 203 "test"
193196 printf("__LINE__=%d __FILE__=%s\n",
194197 __LINE__, __FILE__);
195−#line 195 "tcctest.c"
198+#line 198 "tcctest.c"
196199
197200 /* not strictly preprocessor, but we test it there */
198201 #ifdef C99_MACROS
@@ -208,6 +211,14 @@ void macro_test(void) · 9 unmodified lines
208211
209212 /* complicated macros in glibc */
210213 printf("INT64_MIN=%Ld\n", INT64_MIN);
214+ {
215+ int a;
216+ a = 1;
217+ glue(a+, +);
218+ printf("a=%d\n", a);
219+ glue(a <, <= 2);
220+ printf("a=%d\n", a);
221+ }
211222 }
212223
213224 int op(a,b)
@@ -428,6 +439,9 @@ int main(int argc, char **argv) · 214 unmodified lines
428439 stdarg_test();
429440 whitespace_test();
430441 relocation_test();
442+ old_style_function();
443+ sizeof_test();
444+ typeof_test();
431445 return 0;
432446 }
433447
@@ -466,12 +480,6 @@ void array_test(int a[4]) · 32 unmodified lines
466480
467481 printf("array:\n");
468482 printf("sizeof(a) = %d\n", sizeof(a));
469− printf("sizeof(int) = %d\n", sizeof(int));
470− printf("sizeof(unsigned int) = %d\n", sizeof(unsigned int));
471− printf("sizeof(short) = %d\n", sizeof(short));
472− printf("sizeof(unsigned short) = %d\n", sizeof(unsigned short));
473− printf("sizeof(char) = %d\n", sizeof(char));
474− printf("sizeof(unsigned char) = %d\n", sizeof(unsigned char));
475483 printf("sizeof(\"a\") = %d\n", sizeof("a"));
476484 #ifdef C99_MACROS
477485 printf("sizeof(__func__) = %d\n", sizeof(__func__));
@@ -1502,3 +1510,55 @@ void relocation_test(void) · 1024 unmodified lines
15021510 printf("*rel1=%d\n", *rel1);
15031511 printf("*rel2=%d\n", *rel2);
15041512 }
1513+
1514+void old_style_f(a,b,c)
1515+ int a, b;
1516+ double c;
1517+{
1518+ printf("a=%d b=%d b=%f\n", a, b, c);
1519+}
1520+
1521+void old_style_function(void)
1522+{
1523+ old_style_f((void *)1, 2, 3.0);
1524+}
1525+
1526+void sizeof_test(void)
1527+{
1528+ int a;
1529+ int **ptr;
1530+
1531+ printf("sizeof(int) = %d\n", sizeof(int));
1532+ printf("sizeof(unsigned int) = %d\n", sizeof(unsigned int));
1533+ printf("sizeof(short) = %d\n", sizeof(short));
1534+ printf("sizeof(unsigned short) = %d\n", sizeof(unsigned short));
1535+ printf("sizeof(char) = %d\n", sizeof(char));
1536+ printf("sizeof(unsigned char) = %d\n", sizeof(unsigned char));
1537+ printf("sizeof(func) = %d\n", sizeof sizeof_test());
1538+ a = 1;
1539+ printf("sizeof(a++) = %d\n", sizeof a++);
1540+ printf("a=%d\n", a);
1541+ ptr = NULL;
1542+ printf("sizeof(**ptr) = %d\n", sizeof (**ptr));
1543+
1544+ /* some alignof tests */
1545+ printf("__alignof__(int) = %d\n", __alignof__(int));
1546+ printf("__alignof__(unsigned int) = %d\n", __alignof__(unsigned int));
1547+ printf("__alignof__(short) = %d\n", __alignof__(short));
1548+ printf("__alignof__(unsigned short) = %d\n", __alignof__(unsigned short));
1549+ printf("__alignof__(char) = %d\n", __alignof__(char));
1550+ printf("__alignof__(unsigned char) = %d\n", __alignof__(unsigned char));
1551+ printf("__alignof__(func) = %d\n", __alignof__ sizeof_test());
1552+}
1553+
1554+void typeof_test(void)
1555+{
1556+ double a;
1557+ typeof(a) b;
1558+ typeof(float) c;
1559+
1560+ a = 1.5;
1561+ b = 2.5;
1562+ c = 3.5;
1563+ printf("a=%f b=%f c=%f\n", a, b, c);
1564+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t