]> granicus.if.org Git - clang/commit
Warn when a static variable is referenced in a non-static inline function.
authorJordan Rose <jordan_rose@apple.com>
Fri, 15 Jun 2012 18:19:48 +0000 (18:19 +0000)
committerJordan Rose <jordan_rose@apple.com>
Fri, 15 Jun 2012 18:19:48 +0000 (18:19 +0000)
commit106af9e86adbbb3a05f2c339d509fcd3b4274504
treee249fbff005616367f68c4261ee36b20ca41bc57
parent294e38664f9eefe0ca665739e65dd4fae0108dab
Warn when a static variable is referenced in a non-static inline function.

This is explicitly forbidden in C99 6.7.4p3. This is /not/ forbidden in C++,
probably because by default file-scope const/constexpr variables have internal
linkage, while functions have external linkage. There's also the issue of
anonymous namespaces to consider. Nevertheless, there should probably be a
similar warning, since the semantics of inlining a function that references
a variable with internal linkage do not seem well-defined.

<rdar://problem/11577619>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158531 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExpr.cpp
test/Sema/inline.c