From de92fbee7ebda43bf772a634526ce945d3cbbcf0 Mon Sep 17 00:00:00 2001 From: matthias Date: Fri, 18 Jan 2019 11:01:09 +0100 Subject: [PATCH] add a cleanup test that use a lot of scope --- tests/tests2/101_cleanup.c | 25 ++++++++++++++++++++++++- tests/tests2/101_cleanup.expect | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/tests2/101_cleanup.c b/tests/tests2/101_cleanup.c index 7c3b0ca..4cabf41 100644 --- a/tests/tests2/101_cleanup.c +++ b/tests/tests2/101_cleanup.c @@ -1,5 +1,26 @@ #include +static int glob_i = 0; + +void incr_glob_i(int *i) +{ + glob_i += *i; +} + +#define INCR_GI { \ + int i __attribute__ ((__cleanup__(incr_glob_i))) = 1; \ + } + +#define INCR_GI0 INCR_GI INCR_GI INCR_GI INCR_GI +#define INCR_GI1 INCR_GI0 INCR_GI0 INCR_GI0 INCR_GI0 +#define INCR_GI2 INCR_GI1 INCR_GI1 INCR_GI1 INCR_GI1 +#define INCR_GI3 INCR_GI2 INCR_GI2 INCR_GI2 INCR_GI2 +#define INCR_GI4 INCR_GI3 INCR_GI3 INCR_GI3 INCR_GI3 +#define INCR_GI5 INCR_GI4 INCR_GI4 INCR_GI4 INCR_GI4 +#define INCR_GI6 INCR_GI5 INCR_GI5 INCR_GI5 INCR_GI5 +#define INCR_GI7 INCR_GI6 INCR_GI6 INCR_GI6 INCR_GI6 + + void check2(char **hum); void check(int *j) @@ -103,7 +124,9 @@ int main() __attribute__ ((__cleanup__(check_oh_i))) char oh_i = 'o', o = 'a'; } - naaaaaaaa: + INCR_GI7; + printf("glob_i: %d\n", glob_i); + naaaaaaaa: if (!chk) { __attribute__ ((__cleanup__(check_oh_i))) char oh_i = 'f'; double __attribute__ ((__cleanup__(goto_hell))) f = 2.6; diff --git a/tests/tests2/101_cleanup.expect b/tests/tests2/101_cleanup.expect index 24e6ba3..d4a3559 100644 --- a/tests/tests2/101_cleanup.expect +++ b/tests/tests2/101_cleanup.expect @@ -1,5 +1,6 @@ c: a c: o +glob_i: 65536 oo: 2.600000 c: f str: I don't think this should be print(but gcc got it wrong too)