diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-02 23:23:04 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-02 23:23:04 +0000 |
commit | a9e8b9e3e90fcfe10a04624a89c39b63c32614d1 (patch) | |
tree | c7c964f3ee4549e29043b90e1eb5c7fbec99aea0 /test/Sema/uninit-variables.c | |
parent | af50aab0c317462129d73ae8000c6394c718598d (diff) |
-Wuninitialized: assume that an __attribute__((returns_twice)) function might
initialize any variable. This is extremely conservative, but is sufficient for
now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159620 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/uninit-variables.c')
-rw-r--r-- | test/Sema/uninit-variables.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c index 59577b9585..71ce76c3e3 100644 --- a/test/Sema/uninit-variables.c +++ b/test/Sema/uninit-variables.c @@ -466,3 +466,22 @@ skip_decl: k = produce(); } } + +typedef char jmp_buf[256]; +extern int setjmp(jmp_buf env); // implicitly returns_twice + +void do_stuff_and_longjmp(jmp_buf env, int *result) __attribute__((noreturn)); + +int returns_twice() { + int a; // expected-note {{initialize}} + if (!a) { // expected-warning {{variable 'a' is uninitialized}} + jmp_buf env; + int b; + if (setjmp(env) == 0) { + do_stuff_and_longjmp(env, &b); + } else { + a = b; // no warning + } + } + return a; +} |