diff options
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 7 | ||||
| -rw-r--r-- | clang/unittests/AST/NamedDeclPrinterTest.cpp | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 9c73ee7ede3..30599ea7cfb 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1497,9 +1497,10 @@ void NamedDecl::printQualifiedName(raw_ostream &OS, using ContextsTy = SmallVector<const DeclContext *, 8>; ContextsTy Contexts; - // Collect contexts. - while (Ctx && isa<NamedDecl>(Ctx)) { - Contexts.push_back(Ctx); + // Collect named contexts. + while (Ctx) { + if (isa<NamedDecl>(Ctx)) + Contexts.push_back(Ctx); Ctx = Ctx->getParent(); } diff --git a/clang/unittests/AST/NamedDeclPrinterTest.cpp b/clang/unittests/AST/NamedDeclPrinterTest.cpp index 002bb28f374..5715a341d81 100644 --- a/clang/unittests/AST/NamedDeclPrinterTest.cpp +++ b/clang/unittests/AST/NamedDeclPrinterTest.cpp @@ -173,3 +173,10 @@ TEST(NamedDeclPrinter, TestClassWithScopedNamedEnum) { "A", "X::Y::A")); } + +TEST(NamedDeclPrinter, TestLinkageInNamespace) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( + "namespace X { extern \"C\" { int A; } }", + "A", + "X::A")); +} |

