History

struct-init: Cleanup

Remove dead code and variables. Properly check for unions when skipping fields in initializers. Make tests2/*.expect depend on the .c files so they are automatically rebuilt when the latter change.

Michael Matz committed 10 years ago

Commit 7bf32381 parent ed7d5464 files · +25 −103Browse files

Showing the changes to tests (3 of 4 files). Show all

Unified · Split

3 files
  1. tests/tests2/86-struct-init.c +11 −0
  2. tests/tests2/86-struct-init.expect +1 −0
  3. tests/tests2/Makefile +1 −1
tests/tests2/86-struct-init.c+11−0
@@ -67,6 +67,16 @@ struct V gv3 = {((struct S){7,8,{9,10}}), {"hoho", 49}, 50}; · 66 unmodified lines
6767 /* Initialization of a flex array member (warns in GCC) */
6868 struct W gw = {{1,2,3,4}, {1,2,3,4,5}};
6969
70+union UU {
71+ u8 a;
72+ u8 b;
73+};
74+struct SU {
75+ union UU u;
76+ u8 c;
77+};
78+struct SU gsu = {5,6};
79+
7080 #include <stdio.h>
7181 void print_ (const char *name, const u8 *p, long size)
7282 {
@@ -133,6 +143,7 @@ int main() · 60 unmodified lines
133143 print(gv3);
134144 print(sinit16);
135145 print(gw);
146+ print(gsu);
136147 foo(&gw);
137148 //printf("q: %s\n", q);
138149 return 0;
tests/tests2/86-struct-init.expect+1−0
@@ -12,6 +12,7 @@ gv2: 7 8 9 a 68 69 68 69 0 0 0 0 0 0 0 0 0 0 0 0 2f 30 · 11 unmodified lines
1212 gv3: 7 8 9 a 68 6f 68 6f 0 0 0 0 0 0 0 0 0 0 0 0 31 32
1313 sinit16: 1 0 0 0 2 0 0 0
1414 gw: 1 2 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
15+gsu: 5 6
1516 ls: 1 2 3 4
1617 ls2: 1 2 3 4
1718 lt: 68 65 6c 6c 6f 0 0 0 0 0 0 0 0 0 0 0 2a
tests/tests2/Makefile+1−1
@@ -53,7 +53,7 @@ all test: $(filter-out $(SKIP),$(TESTS)) · 52 unmodified lines
5353 @diff -Nbu $(SRC)/$*.expect $*.output && rm -f $*.output
5454
5555 # automatically generate .expect files with gcc:
56−%.expect :
56+%.expect : %.c
5757 (gcc -w $*.c -o a.exe && ./a.exe $(ARGS)) >$*.expect 2>&1; rm -f a.exe
5858
5959 # tell make not to delete

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