[cfe-commits] r158531 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Sema/inline.c

Eli Friedman eli.friedman at gmail.com
Fri Jun 15 11:38:27 PDT 2012


On Fri, Jun 15, 2012 at 11:19 AM, Jordan Rose <jordan_rose at apple.com> wrote:
> Author: jrose
> Date: Fri Jun 15 13:19:48 2012
> New Revision: 158531
>
> URL: http://llvm.org/viewvc/llvm-project?rev=158531&view=rev
> Log:
> 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.

The equivalent language in C++ is [basic.def.odr]p5.  It's a bit
tricky to diagnose, though.

-Eli



More information about the cfe-commits mailing list