]> granicus.if.org Git - clang/commitdiff
PR19411: Walk lexical parents, not semantic parents, when determining whether a
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 14 Apr 2014 20:23:58 +0000 (20:23 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 14 Apr 2014 20:23:58 +0000 (20:23 +0000)
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
test/CodeGenCXX/extern-c.cpp

index 1de1fe21de3818704e0e90123c1604b4f694ac81..c12f53c6766d8b14d95a37df1ae2e6737e8530fb 100644 (file)
@@ -837,7 +837,7 @@ static bool isLinkageSpecContext(const DeclContext *DC,
   while (DC->getDeclKind() != Decl::TranslationUnit) {
     if (DC->getDeclKind() == Decl::LinkageSpec)
       return cast<LinkageSpecDecl>(DC)->getLanguage() == ID;
-    DC = DC->getParent();
+    DC = DC->getLexicalParent();
   }
   return false;
 }
index 63bb177b84dc4546a948a3b25b90bdb008033f58..fefb216ea1c0ea4551f382222dbeeb66d241d46f 100644 (file)
@@ -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()
+}