History

more tests

bellard committed 24 years ago

Commit 7ab1ac41 parent 12f3f351 file · +40 −4Browse files

Unified · Split

tcctest.c+40−4
@@ -33,7 +33,7 @@ void char_short_test(); · 32 unmodified lines
3333 void init_test(void);
3434 void compound_literal_test(void);
3535 int kr_test();
36−void struct_assign_test();
36+void struct_assign_test(void);
3737 void cast_test(void);
3838 void bitfield_test(void);
3939 void c99_bool_test(void);
@@ -62,6 +62,11 @@ int isid(int c); · 22 unmodified lines
6262 #define dprintf(level,...) printf(__VA_ARGS__)
6363 #endif
6464
65+/* gcc vararg macros */
66+#define dprintf1(level, fmt, args...) printf(fmt, ## args)
67+
68+#define MACRO_NOARGS()
69+
6570 #define AAA 3
6671 #undef AAA
6772 #define AAA 4
@@ -149,6 +154,8 @@ void macro_test() · 81 unmodified lines
149154 printf("test 3\n");
150155 #endif
151156
157+ MACRO_NOARGS();
158+
152159 printf("__LINE__=%d __FILE__=%s\n",
153160 __LINE__, __FILE__);
154161 /* not strictly preprocessor, but we test it there */
@@ -156,6 +163,9 @@ void macro_test() · 1 unmodified line
156163 printf("__func__ = %s\n", __func__);
157164 dprintf(1, "vaarg=%d\n", 1);
158165 #endif
166+ dprintf1(1, "vaarg1\n");
167+ dprintf1(1, "vaarg1=%d\n", 2);
168+ dprintf1(1, "vaarg1=%d %d\n", 1, 2);
159169 }
160170
161171 int op(a,b)
@@ -648,7 +658,7 @@ typedef struct Sym { · 486 unmodified lines
648658
649659 void bool_test()
650660 {
651− int *s, a;
661+ int *s, a, b;
652662
653663 a = 0;
654664 s = (void*)0;
@@ -676,6 +686,13 @@ void bool_test() · 21 unmodified lines
676686
677687 a = 4;
678688 printf("b=%d\n", a + (0 ? 1 : a / 2));
689+
690+ /* test register spilling */
691+ a = 10;
692+ b = 10;
693+ a = (a + b) * ((a < b) ?
694+ ((b - a) * (a - b)): a + b);
695+ printf("a=%d\n", a);
679696 }
680697
681698
@@ -785,10 +802,11 @@ struct structa1 struct_assign_test2(struct structa1 s1, int t) · 103 unmodified lines
785802 return s1;
786803 }
787804
788−void struct_assign_test()
805+void struct_assign_test(void)
789806 {
790807 struct structa1 lsta1, lsta2;
791808
809+#if 0
792810 printf("struct_assign_test:\n");
793811
794812 lsta1.f1 = 1;
@@ -796,7 +814,10 @@ void struct_assign_test() · 1 unmodified line
796814 printf("%d %d\n", lsta1.f1, lsta1.f2);
797815 lsta2 = lsta1;
798816 printf("%d %d\n", lsta2.f1, lsta2.f2);
799−
817+#else
818+ lsta2.f1 = 1;
819+ lsta2.f2 = 2;
820+#endif
800821 struct_assign_test1(lsta2, 3);
801822
802823 printf("before call: %d %d\n", lsta2.f1, lsta2.f2);
@@ -817,6 +838,8 @@ short scast; · 14 unmodified lines
817838 void cast_test()
818839 {
819840 int a;
841+ char c;
842+ char tab[10];
820843
821844 printf("cast_test:\n");
822845 a = 0xfffff;
@@ -837,6 +860,14 @@ void cast_test() · 14 unmodified lines
837860 printf("%d\n", a);
838861 a = (scast = 65536) + 1;
839862 printf("%d\n", a);
863+
864+ printf("sizeof(c) = %d, sizeof((int)c) = %d\n", sizeof(c), sizeof((int)c));
865+
866+ /* test implicit int casting for array accesses */
867+ c = 0;
868+ tab[1] = 2;
869+ tab[c] = 1;
870+ printf("%d %d\n", tab[0], tab[1]);
840871 }
841872
842873 /* initializers tests */
@@ -873,6 +904,7 @@ char *sinit13[] = { · 30 unmodified lines
873904 "test3",
874905 };
875906 char sinit14[10] = { "abc" };
907+int sinit15[3] = { sizeof(sinit15), 1, 2 };
876908
877909 void init_test(void)
878910 {
@@ -887,6 +919,7 @@ void init_test(void) · 8 unmodified lines
887919 char linit14[10] = "abc";
888920 int linit15[10] = { linit1, linit1 + 1, [6] = linit1 + 2, };
889921 struct linit16 { int a1, a2, a3, a4; } linit16 = { 1, .a3 = 2 };
922+ int linit17 = sizeof(linit17);
890923
891924 printf("init_test:\n");
892925
@@ -955,6 +988,9 @@ void init_test(void) · 62 unmodified lines
955988 linit16.a2,
956989 linit16.a3,
957990 linit16.a4);
991+ /* test that initialisation is done after variable declare */
992+ printf("linit17=%d\n", linit17);
993+ printf("sinit15=%d\n", sinit15[0]);
958994 }
959995
960996 void switch_test()

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