зеркало из https://github.com/microsoft/clang.git
extern "C" should preserve the 'extern' qualifier for VarDecls. Fixes 6853728.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71957 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
4ef2770ee5
Коммит
2928c2107f
|
@ -538,8 +538,9 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
|
|||
assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
|
||||
|
||||
// In C++, if this is marked "extern", defer code generation.
|
||||
if (getLangOptions().CPlusPlus &&
|
||||
VD->getStorageClass() == VarDecl::Extern && !VD->getInit())
|
||||
if (getLangOptions().CPlusPlus && !VD->getInit() &&
|
||||
(VD->getStorageClass() == VarDecl::Extern ||
|
||||
VD->isExternC(getContext())))
|
||||
return;
|
||||
|
||||
// In C, if this isn't a definition, defer code generation.
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// RUN: clang-cc -emit-llvm %s -o %t &&
|
||||
namespace foo {
|
||||
|
||||
// RUN: not grep "@a = global i32" %t &&
|
||||
extern "C" int a;
|
||||
|
||||
// RUN: not grep "@_ZN3foo1bE = global i32" %t &&
|
||||
extern int b;
|
||||
|
||||
// RUN: grep "@_ZN3foo1cE = global i32" %t | count 1
|
||||
int c = 5;
|
||||
|
||||
}
|
|
@ -37,7 +37,7 @@ namespace N { namespace N { void f() { } } }
|
|||
extern "C" { namespace N { void unmangled_function() { } } }
|
||||
|
||||
// RUN: grep unmangled_variable %t | count 1 &&
|
||||
extern "C" { namespace N { int unmangled_variable; } }
|
||||
extern "C" { namespace N { int unmangled_variable = 10; } }
|
||||
|
||||
// RUN: grep _ZN1N1iE %t | count 1 &&
|
||||
namespace N { int i; }
|
||||
|
|
Загрузка…
Ссылка в новой задаче