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
67/* Initialization of a flex array member (warns in GCC) */67/* Initialization of a flex array member (warns in GCC) */
68struct W gw = {{1,2,3,4}, {1,2,3,4,5}};68struct W gw = {{1,2,3,4}, {1,2,3,4,5}};
69 69
70union UU {
71 u8 a;
72 u8 b;
73};
74struct SU {
75 union UU u;
76 u8 c;
77};
78struct SU gsu = {5,6};
79
70#include <stdio.h>80#include <stdio.h>
71void print_ (const char *name, const u8 *p, long size)81void print_ (const char *name, const u8 *p, long size)
72{82{
@@ -133,6 +143,7 @@ int main() · 60 unmodified lines
133 print(gv3);143 print(gv3);
134 print(sinit16);144 print(sinit16);
135 print(gw);145 print(gw);
146 print(gsu);
136 foo(&gw);147 foo(&gw);
137 //printf("q: %s\n", q);148 //printf("q: %s\n", q);
138 return 0;149 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
12gv3: 7 8 9 a 68 6f 68 6f 0 0 0 0 0 0 0 0 0 0 0 0 31 3212gv3: 7 8 9 a 68 6f 68 6f 0 0 0 0 0 0 0 0 0 0 0 0 31 32
13sinit16: 1 0 0 0 2 0 0 013sinit16: 1 0 0 0 2 0 0 0
14gw: 1 2 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 014gw: 1 2 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
15gsu: 5 6
15ls: 1 2 3 416ls: 1 2 3 4
16ls2: 1 2 3 417ls2: 1 2 3 4
17lt: 68 65 6c 6c 6f 0 0 0 0 0 0 0 0 0 0 0 2a18lt: 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
53 @diff -Nbu $(SRC)/$*.expect $*.output && rm -f $*.output53 @diff -Nbu $(SRC)/$*.expect $*.output && rm -f $*.output
54 54
55# automatically generate .expect files with gcc:55# automatically generate .expect files with gcc:
56%.expect :56%.expect : %.c
57 (gcc -w $*.c -o a.exe && ./a.exe $(ARGS)) >$*.expect 2>&1; rm -f a.exe57 (gcc -w $*.c -o a.exe && ./a.exe $(ARGS)) >$*.expect 2>&1; rm -f a.exe
58 58
59# tell make not to delete59# 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