From: Anders Carlsson Date: Tue, 22 Sep 2009 17:23:30 +0000 (+0000) Subject: Don't assert that linkage decls are always C++, it's not true. Fixes PR5019. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5cc58c6cfe4a6378287dbf92f9b1a23e133a6118;p=clang Don't assert that linkage decls are always C++, it's not true. Fixes PR5019. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82557 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 973f0d188c..5a994d2234 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -279,11 +279,8 @@ void CXXNameMangler::mangleName(const NamedDecl *ND) { // ::= // const DeclContext *DC = ND->getDeclContext(); - while (isa(DC)) { - assert(cast(DC)->getLanguage() == - LinkageSpecDecl::lang_cxx && "Unexpected linkage decl!"); + while (isa(DC)) DC = DC->getParent(); - } if (DC->isTranslationUnit() || isStdNamespace(DC)) { // Check if we have a template. diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp index d952f31439..dbcd0c9460 100644 --- a/test/CodeGenCXX/mangle.cpp +++ b/test/CodeGenCXX/mangle.cpp @@ -130,3 +130,10 @@ extern "C++" { void h() { } } +// PR5019 +extern "C" { struct a { int b; }; } + +// CHECK: @_Z1fP1a +int f(struct a *x) { + return x->b; +}