Skip to content
Open
8 changes: 5 additions & 3 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -6339,9 +6339,11 @@ def warn_c2y_compat_internal_in_extern_inline : Warning<
"using static %select{function|variable}0 %1 in an inline function with "
"external linkage is incompatible with standards before C2y">,
InGroup<CPre2yCompat>, DefaultIgnore;
def warn_static_local_in_extern_inline : Warning<
"non-constant static local variable in inline function may be different "
"in different files">, InGroup<StaticLocalInInline>;
def warn_static_local_in_extern_inline
: ExtWarn<"non-constant static local variable in inline function may be "
"different "
"in different files">,
InGroup<StaticLocalInInline>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format doesn’t format these properly unfortunately... can you revert all changes here other than changing Warning to ExtWarn?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Added the release note and reverted unrelated formatting changes.

def note_convert_inline_to_static : Note<
"use 'static' to give inline function %0 internal linkage">;

Expand Down
7 changes: 7 additions & 0 deletions clang/test/Sema/inline-static-var.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: %clang_cc1 -std=c11 -Wno-unused-variable -Wno-deprecated-non-prototype -Wno-inline -pedantic-errors -verify %s

inline void f(void) { // expected-note {{use 'static' to give inline function 'f' internal linkage}}
static int x; // expected-error {{non-constant static local variable in inline function may be different in different files}}
}

int main(void) { return 0; }
Loading