From 29edb122e53ee80201a7e535f6e26f161de86a47 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 15 May 2015 14:44:29 -0400 Subject: Output: Do not generate name="" attribute on anonymous namespaces Be consistent with gccxml which did not generate the attribute. --- src/Output.cxx | 5 ++++- test/CMakeLists.txt | 1 + test/expect/gccxml.any.Namespace-anonymous.xml.txt | 8 ++++++++ test/input/Namespace-anonymous.cxx | 5 +++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/expect/gccxml.any.Namespace-anonymous.xml.txt create mode 100644 test/input/Namespace-anonymous.cxx 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 << " 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 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"\?> +]*> + + + + + +$ 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; + } +} -- cgit v0.12