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). --- clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp | 35 ++++++++++++ clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp | 6 ++ clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp | 79 ++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp create mode 100644 clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp (limited to 'clang/test/CXX/temp/temp.decls/temp.mem') diff --git a/clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp new file mode 100644 index 0000000..f5f1205 --- /dev/null +++ b/clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template struct A { + static T cond; + + template struct B { + static T twice(U value) { + return (cond ? value + value : value); + } + }; +}; + +int foo() { + A::cond = true; + return A::B::twice(4); +} + +namespace PR6376 { + template + struct X { + template + struct Y1 { }; // + }; + + template<> + struct X { + template + struct Y1 { }; + }; + + template + struct Z : public X::template Y1 { }; + + Z z0; +} diff --git a/clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp b/clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp new file mode 100644 index 0000000..0eb747b --- /dev/null +++ b/clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template struct AA { + template virtual void g(C); // expected-error{{'virtual' can not be specified on member function templates}} + virtual void f(); +}; diff --git a/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp b/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp new file mode 100644 index 0000000..8bcd773 --- /dev/null +++ b/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp @@ -0,0 +1,79 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +struct A { + template operator T*(); +}; + +template A::operator T*() { return 0; } +template <> A::operator char*(){ return 0; } // specialization +template A::operator void*(); // explicit instantiation + +int main() { + A a; + int *ip; + ip = a.operator int*(); +} + +// PR5742 +namespace PR5742 { + template struct A { }; + template struct B { }; + + struct S { + template operator T(); + } s; + + void f() { + s.operator A >(); + s.operator A >(); + s.operator A > >(); + } +} + +// PR5762 +class Foo { + public: + template operator T(); + + template + T As() { + return this->operator T(); + } + + template + T As2() { + return operator T(); + } + + int AsInt() { + return this->operator int(); + } +}; + +template float Foo::As(); +template double Foo::As2(); + +// Partial ordering with conversion function templates. +struct X0 { + template operator T*() { + T x = 1; + x = 17; // expected-error{{read-only variable is not assignable}} + } + + template operator T*() const; // expected-note{{explicit instantiation refers here}} + + template operator const T*() const { + T x = T(); + return x; // expected-error{{cannot initialize return object of type 'const char *' with an lvalue of type 'char'}} \ + // expected-error{{cannot initialize return object of type 'const int *' with an lvalue of type 'int'}} + } +}; + +template X0::operator const char*() const; // expected-note{{'X0::operator const char *' requested here}} +template X0::operator const int*(); // expected-note{{'X0::operator const int *' requested here}} +template X0::operator float*() const; // expected-error{{explicit instantiation of undefined function template}} + +void test_X0(X0 x0, const X0 &x0c) { + x0.operator const int*(); // expected-note{{in instantiation of function template specialization}} + x0.operator float *(); + x0c.operator const char*(); +} -- cgit v1.2.3