History

add a cleanup test that use a lot of scope

matthias committed 7 years ago

Commit de92fbe1 parent 26f0cf02 files · +25 −1Browse files

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

Unified · Split

2 files
  1. tests/tests2/101_cleanup.c +24 −1
  2. tests/tests2/101_cleanup.expect +1 −0
tests/tests2/101_cleanup.c+24−1
@@ -1,5 +1,26 @@
1#include <tcclib.h>1#include <tcclib.h>
2 2
3static int glob_i = 0;
4
5void incr_glob_i(int *i)
6{
7 glob_i += *i;
8}
9
10#define INCR_GI { \
11 int i __attribute__ ((__cleanup__(incr_glob_i))) = 1; \
12 }
13
14#define INCR_GI0 INCR_GI INCR_GI INCR_GI INCR_GI
15#define INCR_GI1 INCR_GI0 INCR_GI0 INCR_GI0 INCR_GI0
16#define INCR_GI2 INCR_GI1 INCR_GI1 INCR_GI1 INCR_GI1
17#define INCR_GI3 INCR_GI2 INCR_GI2 INCR_GI2 INCR_GI2
18#define INCR_GI4 INCR_GI3 INCR_GI3 INCR_GI3 INCR_GI3
19#define INCR_GI5 INCR_GI4 INCR_GI4 INCR_GI4 INCR_GI4
20#define INCR_GI6 INCR_GI5 INCR_GI5 INCR_GI5 INCR_GI5
21#define INCR_GI7 INCR_GI6 INCR_GI6 INCR_GI6 INCR_GI6
22
23
3void check2(char **hum);24void check2(char **hum);
4 25
5void check(int *j)26void check(int *j)
@@ -103,7 +124,9 @@ int main() · 97 unmodified lines
103 __attribute__ ((__cleanup__(check_oh_i))) char oh_i = 'o', o = 'a';124 __attribute__ ((__cleanup__(check_oh_i))) char oh_i = 'o', o = 'a';
104 }125 }
105 126
106 naaaaaaaa:127 INCR_GI7;
128 printf("glob_i: %d\n", glob_i);
129 naaaaaaaa:
107 if (!chk) {130 if (!chk) {
108 __attribute__ ((__cleanup__(check_oh_i))) char oh_i = 'f';131 __attribute__ ((__cleanup__(check_oh_i))) char oh_i = 'f';
109 double __attribute__ ((__cleanup__(goto_hell))) f = 2.6;132 double __attribute__ ((__cleanup__(goto_hell))) f = 2.6;
tests/tests2/101_cleanup.expect+1−0
@@ -1,5 +1,6 @@
1c: a1c: a
2c: o2c: o
3glob_i: 65536
3oo: 2.6000004oo: 2.600000
4c: f5c: f
5str: I don't think this should be print(but gcc got it wrong too)6str: I don't think this should be print(but gcc got it wrong too)

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