diff options
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 10 | ||||
-rw-r--r-- | test/CodeGenCXX/mangle.cpp | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 1c84f28d5b..6e62fcfc2e 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -109,6 +109,16 @@ bool CXXNameMangler::mangle(const NamedDecl *D) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) return mangleFunctionDecl(FD); + if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { + if (!Context.getLangOptions().CPlusPlus || + isInCLinkageSpecification(D)) + return false; + + Out << "_Z"; + mangleName(VD); + return true; + } + return false; } diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp index 64a3b05cfa..e9a76c93f0 100644 --- a/test/CodeGenCXX/mangle.cpp +++ b/test/CodeGenCXX/mangle.cpp @@ -36,6 +36,8 @@ namespace N { namespace N { void f() { } } } // RUN: grep unmangled_function %t | count 1 && extern "C" { namespace N { void unmangled_function() { } } } -// RUN: grep unmangled_variable %t | count 1 +// RUN: grep unmangled_variable %t | count 1 && extern "C" { namespace N { int unmangled_variable; } } +// RUN: grep _ZN1N1iE %t | count 1 +namespace N { int i; } |