From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- .../test/SemaTemplate/instantiation-default-1.cpp | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 clang/test/SemaTemplate/instantiation-default-1.cpp (limited to 'clang/test/SemaTemplate/instantiation-default-1.cpp') diff --git a/clang/test/SemaTemplate/instantiation-default-1.cpp b/clang/test/SemaTemplate/instantiation-default-1.cpp new file mode 100644 index 0000000..99154a5 --- /dev/null +++ b/clang/test/SemaTemplate/instantiation-default-1.cpp @@ -0,0 +1,102 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +template struct Def1; + +template<> struct Def1 { + void foo(); +}; + +template<> struct Def1 { // expected-note{{previous definition is here}} + void bar(); +}; + +template<> struct Def1 { + void wibble(); +}; + +void test_Def1(Def1 *d1, Def1 *d2, + Def1 *d3) { + d1->foo(); + d2->bar(); + d3->wibble(); +} + +template // expected-error{{'T2' declared as a pointer to a reference}} + struct Def2; + +template<> struct Def2 { + void foo(); +}; + +void test_Def2(Def2 *d2) { + d2->foo(); +} + +typedef int& int_ref_t; +Def2 *d2; // expected-note{{in instantiation of default argument for 'Def2' required here}} + + +template<> struct Def1 { }; // expected-error{{redefinition of 'Def1'}} + +template struct Def3; + +template<> struct Def3 { + void foo(); +}; + +template<> struct Def3 { + void bar(); +}; + +void test_Def3(Def3 *d3a, Def3 *d3b) { + d3a->foo(); + d3b->bar(); +} + + +template struct Def4; + +template<> struct Def4 { + void foo(); +}; + +void test_Def4(Def4 *d4a) { + d4a->foo(); +} + +template struct Def5; + +template<> struct Def5 { + void foo(); +}; + +template<> struct Def5 { + void bar(); +}; + +void test_Def5(Def5 *d5a, Def5 *d5b) { + d5a->foo(); + d5b->bar(); +} + +template + struct Def6; + +template<> struct Def6 { + void foo(); +}; + +template<> struct Def6 { + void bar(); +}; + +bool test_Def6(Def6 *d6a, + Def6 *d6b, + Def6 *d6c) { + d6a->foo(); + d6b->foo(); + d6c->bar(); + return d6a == d6b; +} -- cgit v1.2.3