From dff60442ebc763839c28c94c93d2ae4e4de3fad6 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 14 Apr 2014 20:23:58 +0000 Subject: [PATCH] PR19411: Walk lexical parents, not semantic parents, when determining whether a DeclContext is (lexically) within a C language linkage specification. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206204 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/DeclBase.cpp | 2 +- test/CodeGenCXX/extern-c.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 1de1fe21de..c12f53c676 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -837,7 +837,7 @@ static bool isLinkageSpecContext(const DeclContext *DC, while (DC->getDeclKind() != Decl::TranslationUnit) { if (DC->getDeclKind() == Decl::LinkageSpec) return cast(DC)->getLanguage() == ID; - DC = DC->getParent(); + DC = DC->getLexicalParent(); } return false; } diff --git a/test/CodeGenCXX/extern-c.cpp b/test/CodeGenCXX/extern-c.cpp index 63bb177b84..fefb216ea1 100644 --- a/test/CodeGenCXX/extern-c.cpp +++ b/test/CodeGenCXX/extern-c.cpp @@ -66,3 +66,10 @@ extern "C" { // CHECK-NOT: @unused // CHECK-NOT: @duplicate_internal } + +namespace PR19411 { + struct A { void f(); }; + extern "C" void A::f() { void g(); g(); } + // CHECK-LABEL: @_ZN7PR194111A1fEv( + // CHECK: call void @g() +} -- 2.40.0