forked from OSchip/llvm-project
Reword -Winternal-linkage-in-inline, and rename it to -Wstatic-in-inline.
Now that this is a C-only warning, we can use "static" instead of "internal linkage", which is a term developers are probably more familiar with. This makes for a better warning message. The warning name was changed to match, since "internal linkage" is not mentioned in the warning text anymore. llvm-svn: 158853
This commit is contained in:
parent
0187a05e35
commit
dc753b625f
|
@ -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<DiagGroup<"internal-linkage-in-inline"> >;
|
||||
"static %select{function|variable}0 %1 is used in an inline function with "
|
||||
"external linkage">, InGroup<DiagGroup<"static-in-inline"> >;
|
||||
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<DiagGroup<"internal-linkage-in-inline"> >;
|
||||
"static %select{function|variable}0 %1 is used in an inline function with "
|
||||
"external linkage">, InGroup<DiagGroup<"static-in-inline"> >;
|
||||
def note_convert_inline_to_static : Note<
|
||||
"use 'static' to give inline function %0 internal linkage">;
|
||||
def note_internal_decl_declared_here : Note<
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue