diff options
author | John McCall <rjmccall@apple.com> | 2013-04-02 02:48:58 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2013-04-02 02:48:58 +0000 |
commit | c87d97231d124952cef90b8717066c940afab409 (patch) | |
tree | 2a7db3ed4f7d3b5a5e03fda14a6a81c80d60827c /clang/test/Sema/inline.c | |
parent | e1d88cfb57f806fe87c4650379538ededa30dbc8 (diff) | |
download | bcm5719-llvm-c87d97231d124952cef90b8717066c940afab409.tar.gz bcm5719-llvm-c87d97231d124952cef90b8717066c940afab409.zip |
Add -Wstatic-local-in-inline, which warns about using a static local
variable in a C99 inline (but not static-inline or extern-inline)
function definition.
The standard doesn't actually say that this doesn't apply to
"extern inline" definitions, but that seems like a useful extension,
and it at least doesn't have the obvious flaw that a static
mutable variable in an externally-available definition does.
rdar://13535367
llvm-svn: 178520
Diffstat (limited to 'clang/test/Sema/inline.c')
-rw-r--r-- | clang/test/Sema/inline.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/Sema/inline.c b/clang/test/Sema/inline.c index c27c00efaad..496e282ecac 100644 --- a/clang/test/Sema/inline.c +++ b/clang/test/Sema/inline.c @@ -73,6 +73,16 @@ inline int useStaticAgain () { // expected-note 2 {{use 'static' to give inline #pragma clang diagnostic pop +inline void defineStaticVar() { // expected-note {{use 'static' to give inline function 'defineStaticVar' internal linkage}} + static const int x = 0; // ok + static int y = 0; // expected-warning {{non-constant static local variable in inline function may be different in different files}} +} + +extern inline void defineStaticVarInExtern() { + static const int x = 0; // ok + static int y = 0; // ok +} + #endif |