summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Output.cxx5
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/expect/gccxml.Class-template-friends-xml.txt22
-rw-r--r--test/input/Class-template-friends.cxx8
4 files changed, 36 insertions, 0 deletions
diff --git a/src/Output.cxx b/src/Output.cxx
index a771057..6344b8d 100644
--- a/src/Output.cxx
+++ b/src/Output.cxx
@@ -947,6 +947,11 @@ void ASTVisitor::PrintBefriendingAttribute(clang::CXXRecordDecl const* dx)
e = dx->friend_end(); i != e; ++i) {
clang::FriendDecl const* fd = *i;
if(clang::NamedDecl const* nd = fd->getFriendDecl()) {
+ if(nd->isTemplateDecl()) {
+ // gccxml output format does not have uninstantiated templates
+ continue;
+ }
+
if(unsigned int id = this->AddDumpNode(nd, false)) {
this->OS << sep << "_" << id;
sep = " ";
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index fd35886..158215a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -104,6 +104,7 @@ castxml_test_gccxml(Class-member-template)
castxml_test_gccxml(Class-template)
castxml_test_gccxml(Class-template-Method-Argument-default)
castxml_test_gccxml(Class-template-bases)
+castxml_test_gccxml(Class-template-friends)
castxml_test_gccxml(Class-template-member-Typedef)
castxml_test_gccxml(Class-template-member-template)
castxml_test_gccxml(CvQualifiedType)
diff --git a/test/expect/gccxml.Class-template-friends-xml.txt b/test/expect/gccxml.Class-template-friends-xml.txt
new file mode 100644
index 0000000..8bcd543
--- /dev/null
+++ b/test/expect/gccxml.Class-template-friends-xml.txt
@@ -0,0 +1,22 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Class id="_1" name="start&lt;int&gt;" context="_2" location="f1:8" file="f1" line="8" members="_3 _4 _5 _6" befriending="_7 _8"/>
+ <Constructor id="_3" name="start" context="_1" access="public" location="f1:8" file="f1" line="8" inline="1" artificial="1"/>
+ <Constructor id="_4" name="start" context="_1" access="public" location="f1:8" file="f1" line="8" inline="1" artificial="1">
+ <Argument type="_9" location="f1:8" file="f1" line="8"/>
+ </Constructor>
+ <OperatorMethod id="_5" name="=" returns="_10" context="_1" access="public" location="f1:8" file="f1" line="8" inline="1" artificial="1">
+ <Argument type="_9" location="f1:8" file="f1" line="8"/>
+ </OperatorMethod>
+ <Destructor id="_6" name="start" context="_1" access="public" location="f1:8" file="f1" line="8" inline="1" artificial="1"/>
+ <ReferenceType id="_9" type="_1c"/>
+ <ReferenceType id="_10" type="_1"/>
+ <Namespace id="_2" name="::"/>
+ <Class id="_8" name="A&lt;int&gt;" context="_2" location="f1:1" file="f1" line="1" incomplete="1"/>
+ <Function id="_7" name="f" returns="_12" context="_2" location="f1:5" file="f1" line="5">
+ <Argument type="_12" location="f1:2" file="f1" line="2"/>
+ </Function>
+ <CvQualifiedType id="_1c" type="_1" const="1"/>
+ <FundamentalType id="_12" name="int"/>
+ <File id="f1" name=".*/test/input/Class-template-friends.cxx"/>
+</GCC_XML>$
diff --git a/test/input/Class-template-friends.cxx b/test/input/Class-template-friends.cxx
new file mode 100644
index 0000000..e1b3166
--- /dev/null
+++ b/test/input/Class-template-friends.cxx
@@ -0,0 +1,8 @@
+template <typename T> class A;
+template <typename T> int f(T);
+template <typename T> class start {
+ friend class A<T>;
+ friend int f<T>(T);
+ template <typename U> friend int f(U);
+};
+template class start<int>;