c: privide deprecated warning when __private_extern__ storage
specifier is unsed in a declaration; as it may not make the symbol local to linkage unit as intended. Suggest using "hidden" visibility attribute instead. // rdar://7703982 llvm-svn: 162138
This commit is contained in:
parent
257c5f2088
commit
f85f338634
|
@ -1490,10 +1490,10 @@ def note_non_literal_user_provided_dtor : Note<
|
|||
def note_non_literal_nontrivial_dtor : Note<
|
||||
"%0 is not literal because it has a non-trivial destructor">;
|
||||
def warn_private_extern : Warning<
|
||||
"Use of __private_extern__ on tentative definition has unexpected"
|
||||
" behaviour - use __attribute__((visibility(\"hidden\"))) on extern"
|
||||
" declaration or definition instead">,
|
||||
InGroup<PrivateExtern>, DefaultIgnore;
|
||||
"use of __private_extern__ on a declaration may not produce external symbol "
|
||||
"private to the linkage unit and is deprecated">, InGroup<PrivateExtern>;
|
||||
def note_private_extern : Note<
|
||||
"use __attribute__((visibility(\"hidden\"))) attribute instead">;
|
||||
|
||||
// C++11 char16_t/char32_t
|
||||
def warn_cxx98_compat_unicode_type : Warning<
|
||||
|
|
|
@ -6758,8 +6758,10 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl,
|
|||
AbstractVariableType))
|
||||
Var->setInvalidDecl();
|
||||
if (!Type->isDependentType() && !Var->isInvalidDecl() &&
|
||||
Var->getStorageClass() == SC_PrivateExtern)
|
||||
Var->getStorageClass() == SC_PrivateExtern) {
|
||||
Diag(Var->getLocation(), diag::warn_private_extern);
|
||||
Diag(Var->getLocation(), diag::note_private_extern);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 %s -triple i386-pc-linux-gnu -verify -fsyntax-only
|
||||
// RUN: %clang_cc1 %s -Wno-private-extern -triple i386-pc-linux-gnu -verify -fsyntax-only
|
||||
|
||||
void f() {
|
||||
int i;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -verify -fsyntax-only %s
|
||||
// RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern %s
|
||||
|
||||
extern int l0 __attribute__((used)); // expected-warning {{used attribute ignored}}
|
||||
__private_extern__ int l1 __attribute__((used)); // expected-warning {{used attribute ignored}}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -verify -fsyntax-only %s
|
||||
// RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern %s
|
||||
|
||||
static int g0; // expected-note{{previous definition}}
|
||||
int g0; // expected-error{{non-static declaration of 'g0' follows static declaration}}
|
||||
|
|
|
@ -33,7 +33,8 @@ static int i3 = 5;
|
|||
extern int i3;
|
||||
|
||||
// rdar://7703982
|
||||
__private_extern__ int pExtern; // expected-warning {{Use of __private_extern__ on tentative definition has unexpected behaviour}}
|
||||
__private_extern__ int pExtern; // expected-warning {{use of __private_extern__ on a declaration may not produce external symbol private to the linkage unit and is deprecated}} \
|
||||
// expected-note {{use __attribute__((visibility("hidden"))) attribute instead}}
|
||||
int pExtern = 0;
|
||||
|
||||
int i4;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify -pedantic %s
|
||||
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s
|
||||
|
||||
__thread int t1;
|
||||
__thread extern int t2; // expected-warning {{'__thread' before 'extern'}}
|
||||
|
|
Loading…
Reference in New Issue