forked from OSchip/llvm-project
Error if an extern C declaration matches a previous hidden extern C declaration.
Without this patch we produce an error for extern "C" { void f() { extern int b; } } extern "C" { extern float b; } but not for extern "C" { void f() { extern int b; } } extern "C" { float b; } llvm-svn: 176867
This commit is contained in:
parent
b3f4b978bb
commit
15770b2f3d
|
@ -5004,10 +5004,7 @@ void Sema::CheckShadow(Scope *S, VarDecl *D) {
|
|||
|
||||
template<typename T>
|
||||
static bool mayConflictWithNonVisibleExternC(const T *ND) {
|
||||
VarDecl::StorageClass SC = ND->getStorageClass();
|
||||
if (ND->isExternC() && (SC == SC_Extern || SC == SC_PrivateExtern))
|
||||
return true;
|
||||
return ND->getDeclContext()->isTranslationUnit();
|
||||
return ND->isExternC() || ND->getDeclContext()->isTranslationUnit();
|
||||
}
|
||||
|
||||
/// \brief Perform semantic checking on a newly-created variable
|
||||
|
|
|
@ -134,3 +134,14 @@ namespace test3 {
|
|||
}
|
||||
}
|
||||
float test3_x; // expected-error {{redefinition of 'test3_x' with a different type: 'float' vs 'int'}}
|
||||
|
||||
namespace test4 {
|
||||
extern "C" {
|
||||
void f() {
|
||||
extern int b; // expected-note {{previous definition is here}}
|
||||
}
|
||||
}
|
||||
extern "C" {
|
||||
float b; // expected-error {{redefinition of 'b' with a different type: 'float' vs 'int'}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue