diff options
author | Brad King <brad.king@kitware.com> | 2014-03-27 17:04:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-27 18:14:19 (GMT) |
commit | fc66c82e1de6afd4453b7223c51de50428a40769 (patch) | |
tree | b75a56e010a74b00ed3d7d9979688faf3652cb14 /test | |
parent | f2d0fdfe812c7f96d8193194a5840ff011aa7ec8 (diff) | |
download | CastXML-fc66c82e1de6afd4453b7223c51de50428a40769.zip CastXML-fc66c82e1de6afd4453b7223c51de50428a40769.tar.gz CastXML-fc66c82e1de6afd4453b7223c51de50428a40769.tar.bz2 |
test: Show duplication of reference-to-class-template-specialization types
Clang generates a distinct TemplateSpecializationType for each
appearance of A<T> for some template A<>. They are all sugar for an
underlying RecordType. While they all share the same canonical type,
LValueReferenceType instances that refer to them are also distinct and
do not share the same canonical type because each has a different
pointee type.
Add tests demonstrating cases where this causes duplicate ReferenceType
elements to be generated. Mark them as "broken" and add a note in the
expected output that matches nothing but documents the problem.
Diffstat (limited to 'test')
5 files changed, 63 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8c50ce2..2d376ba 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -48,6 +48,10 @@ macro(castxml_test_gccxml test) castxml_test_gccxml_common(gccxml cxx -std=c++98 ${test}) endmacro() +macro(castxml_test_gccxml_broken test) + castxml_test_gccxml_common(gccxml.broken cxx -std=c++98 ${test}) +endmacro() + macro(castxml_test_gccxml_c test) castxml_test_gccxml_common(gccxml.c c -std=c89 ${test}) endmacro() @@ -148,3 +152,6 @@ castxml_test_gccxml_c(FundamentalType) castxml_test_gccxml_c(Typedef-called-class) castxml_test_gccxml_c(invalid) + +castxml_test_gccxml_broken(Class-template-constructor-template) +castxml_test_gccxml_broken(ReferenceType-to-Class-template) diff --git a/test/expect/gccxml.broken.Class-template-constructor-template-xml.txt b/test/expect/gccxml.broken.Class-template-constructor-template-xml.txt new file mode 100644 index 0000000..8fa2b4b --- /dev/null +++ b/test/expect/gccxml.broken.Class-template-constructor-template-xml.txt @@ -0,0 +1,21 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Class id="_1" name="start<int>" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6"/> + <Constructor id="_3" name="start" context="_1" access="public" location="f1:3" file="f1" line="3"> + <Argument type="_7" location="f1:3" file="f1" line="3"/> + </Constructor> + <Constructor id="_4" name="start" context="_1" access="public" location="f1:4" file="f1" line="4"> + <Argument type="_8" location="f1:4" file="f1" line="4"/> + </Constructor> + <OperatorMethod id="_5" name="=" returns="_9" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"> + <Argument type="_7" location="f1:1" file="f1" line="1"/> + </OperatorMethod> + <Destructor id="_6" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"/> + <ReferenceType id="_7" type="_1c"/> + <ReferenceType id="_8" type="_1c"/>(broken: duplicate ReferenceType)? + <ReferenceType id="_9" type="_1"/> + <Namespace id="_2" name="::"/> + <CvQualifiedType id="_1c" type="_1" const="1"/> + <CvQualifiedType id="_1c" type="_1" const="1"/> + <File id="f1" name=".*/test/input/Class-template-constructor-template.cxx"/> +</GCC_XML>$ diff --git a/test/expect/gccxml.broken.ReferenceType-to-Class-template-xml.txt b/test/expect/gccxml.broken.ReferenceType-to-Class-template-xml.txt new file mode 100644 index 0000000..6c01a34 --- /dev/null +++ b/test/expect/gccxml.broken.ReferenceType-to-Class-template-xml.txt @@ -0,0 +1,25 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Function id="_1" name="start" returns="_4" context="_5" location="f1:2" file="f1" line="2"> + <Argument type="_6" location="f1:2" file="f1" line="2"/> + <Argument type="_7" location="f1:2" file="f1" line="2"/> + </Function> + <Function id="_2" name="start" returns="_4" context="_5" location="f1:3" file="f1" line="3"> + <Argument type="_8" location="f1:3" file="f1" line="3"/> + <Argument type="_9" location="f1:3" file="f1" line="3"/> + </Function> + <Function id="_3" name="start" returns="_4" context="_5" location="f1:4" file="f1" line="4"> + <Argument type="_10" location="f1:4" file="f1" line="4"/> + <Argument type="_11" location="f1:4" file="f1" line="4"/> + </Function> + <FundamentalType id="_4" name="void"/> + <ReferenceType id="_6" type="_12"/> + <FundamentalType id="_7" name="short int"/> + <ReferenceType id="_8" type="_12"/>(broken: duplicate ReferenceType)? + <FundamentalType id="_9" name="int"/> + <ReferenceType id="_10" type="_12"/>(broken: duplicate ReferenceType)? + <FundamentalType id="_11" name="long int"/> + <Namespace id="_5" name="::"/> + <Class id="_12" name="A<int>" context="_5" location="f1:1" file="f1" line="1" incomplete="1"/> + <File id="f1" name=".*/test/input/ReferenceType-to-Class-template.cxx"/> +</GCC_XML>$ diff --git a/test/input/Class-template-constructor-template.cxx b/test/input/Class-template-constructor-template.cxx new file mode 100644 index 0000000..1ca5d93 --- /dev/null +++ b/test/input/Class-template-constructor-template.cxx @@ -0,0 +1,6 @@ +template <typename T> class start { +public: + start(start const&); + template <typename U> start(start<U> const&); +}; +start<int> instantiate_and_copy(start<int> const& x) { return x; } diff --git a/test/input/ReferenceType-to-Class-template.cxx b/test/input/ReferenceType-to-Class-template.cxx new file mode 100644 index 0000000..2bf8bbb --- /dev/null +++ b/test/input/ReferenceType-to-Class-template.cxx @@ -0,0 +1,4 @@ +template <typename T> class A {}; +void start(A<int>&, short); +void start(A<int>&, int); +void start(A<int>&, long); |