diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index ae21c69b2d3c5..f0f81f64e179e 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -404,6 +404,10 @@ Improvements to Clang's diagnostics - Clang now emits a diagnostic in case `vector_size` or `ext_vector_type` attributes are used with a negative size (#GH165463). +- The warning about static local variables declared inside `inline` + functions is now correctly converted to an error if `-pedantic-errors` is + passed (#GH39524). + Improvements to Clang's time-trace ---------------------------------- diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index fa509536bf021..7f10a0cd0a770 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -6339,7 +6339,7 @@ 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, DefaultIgnore; -def warn_static_local_in_extern_inline : Warning< +def warn_static_local_in_extern_inline : ExtWarn< "non-constant static local variable in inline function may be different " "in different files">, InGroup; def note_convert_inline_to_static : Note< diff --git a/clang/test/Sema/inline-static-var.c b/clang/test/Sema/inline-static-var.c new file mode 100644 index 0000000000000..16351dee26663 --- /dev/null +++ b/clang/test/Sema/inline-static-var.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c11 -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}} +} +