diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 1e9069a7db95..1b26b7b1a749 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3022,13 +3022,11 @@ def warn_undefined_internal : Warning< def note_used_here : Note<"used here">; def warn_internal_in_extern_inline : ExtWarn< - "%select{function|variable}0 %1 has internal linkage but is used in an " - "inline function with external linkage">, - InGroup >; + "static %select{function|variable}0 %1 is used in an inline function with " + "external linkage">, InGroup >; def ext_internal_in_extern_inline : Extension< - "%select{function|variable}0 %1 has internal linkage but is used in an " - "inline function with external linkage">, - InGroup >; + "static %select{function|variable}0 %1 is used in an inline function with " + "external linkage">, InGroup >; def note_convert_inline_to_static : Note< "use 'static' to give inline function %0 internal linkage">; def note_internal_decl_declared_here : Note< diff --git a/clang/test/Sema/inline.c b/clang/test/Sema/inline.c index 7f1815e467da..6c95a7a14b4c 100644 --- a/clang/test/Sema/inline.c +++ b/clang/test/Sema/inline.c @@ -8,15 +8,17 @@ // Check the use of static variables in non-static inline functions. static int staticVar; // expected-note + {{'staticVar' declared here}} static int staticFunction(); // expected-note + {{'staticFunction' declared here}} +static struct { int x; } staticStruct; // expected-note + {{'staticStruct' declared here}} -inline int useStatic () { // expected-note 2 {{use 'static' to give inline function 'useStatic' internal linkage}} - staticFunction(); // expected-warning{{function 'staticFunction' has internal linkage but is used in an inline function with external linkage}} - return staticVar; // expected-warning{{variable 'staticVar' has internal linkage but is used in an inline function with external linkage}} +inline int useStatic () { // expected-note 3 {{use 'static' to give inline function 'useStatic' internal linkage}} + staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}} + (void)staticStruct.x; // expected-warning{{static variable 'staticStruct' is used in an inline function with external linkage}} + return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}} } extern inline int useStaticFromExtern () { // no suggestions - staticFunction(); // expected-warning{{function 'staticFunction' has internal linkage but is used in an inline function with external linkage}} - return staticVar; // expected-warning{{variable 'staticVar' has internal linkage but is used in an inline function with external linkage}} + staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}} + return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}} } static inline int useStaticFromStatic () { @@ -48,11 +50,11 @@ inline int useStaticMainFile () { // Check that the warnings show up when explicitly requested. #pragma clang diagnostic push -#pragma clang diagnostic warning "-Winternal-linkage-in-inline" +#pragma clang diagnostic warning "-Wstatic-in-inline" inline int useStaticAgain () { // expected-note 2 {{use 'static' to give inline function 'useStaticAgain' internal linkage}} - staticFunction(); // expected-warning{{function 'staticFunction' has internal linkage but is used in an inline function with external linkage}} - return staticVar; // expected-warning{{variable 'staticVar' has internal linkage but is used in an inline function with external linkage}} + staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}} + return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}} } #pragma clang diagnostic pop