diff options
-rw-r--r-- | src/Output.cxx | 5 | ||||
-rw-r--r-- | test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/expect/gccxml.any.Namespace-anonymous.xml.txt | 8 | ||||
-rw-r--r-- | test/input/Namespace-anonymous.cxx | 5 |
4 files changed, 18 insertions, 1 deletions
diff --git a/src/Output.cxx b/src/Output.cxx index 374f1c3..709c5b8 100644 --- a/src/Output.cxx +++ b/src/Output.cxx @@ -1373,7 +1373,10 @@ void ASTVisitor::OutputNamespaceDecl( { this->OS << " <Namespace"; this->PrintIdAttribute(dn); - this->PrintNameAttribute(d->getName().str()); + std::string name = d->getName().str(); + if (!name.empty()) { + this->PrintNameAttribute(name); + } this->PrintContextAttribute(d); if(dn->Complete) { std::set<DumpId> emitted; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 76ccf23..12f3fe5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -188,6 +188,7 @@ castxml_test_gccxml(Method-rvalue-reference) castxml_test_gccxml(MethodType) castxml_test_gccxml(MethodType-cv) castxml_test_gccxml(Namespace) +castxml_test_gccxml(Namespace-anonymous) castxml_test_gccxml(Namespace-Class-members) castxml_test_gccxml(Namespace-Class-partial-template-members) castxml_test_gccxml(Namespace-Class-template-members) diff --git a/test/expect/gccxml.any.Namespace-anonymous.xml.txt b/test/expect/gccxml.any.Namespace-anonymous.xml.txt new file mode 100644 index 0000000..12c2c4d --- /dev/null +++ b/test/expect/gccxml.any.Namespace-anonymous.xml.txt @@ -0,0 +1,8 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Namespace id="_1" name="start" context="_2" members="_3"/> + <Namespace id="_3" context="_1" members="_4"/> + <Struct id="_4" name="A" context="_3" location="f1:3" file="f1" line="3" incomplete="1"/> + <Namespace id="_2" name="::"/> + <File id="f1" name=".*/test/input/Namespace-anonymous.cxx"/> +</GCC_XML>$ diff --git a/test/input/Namespace-anonymous.cxx b/test/input/Namespace-anonymous.cxx new file mode 100644 index 0000000..f35a1ab --- /dev/null +++ b/test/input/Namespace-anonymous.cxx @@ -0,0 +1,5 @@ +namespace start { + namespace { + struct A; + } +} |