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). --- .../temp/temp.fct.spec/temp.arg.explicit/p1.cpp | 12 ++++ .../temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp | 27 +++++++++ .../temp.arg.explicit/p3-nodeduct.cpp | 36 ++++++++++++ .../temp/temp.fct.spec/temp.arg.explicit/p3.cpp | 65 +++++++++++++++++++++ .../temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp | 68 ++++++++++++++++++++++ 5 files changed, 208 insertions(+) create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp (limited to 'clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit') diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp new file mode 100644 index 0000000..0aef6ad --- /dev/null +++ b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only %s + +template struct A { }; + +template T make(); +template T make2(const T&); + +void test_make() { + int& ir0 = make(); + A a0 = make< A >(); + A a1 = make2< A >(A()); +} diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp new file mode 100644 index 0000000..4d29b74 --- /dev/null +++ b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +namespace ParameterPacksWithFunctions { + template struct count; + + template + struct count { + static const unsigned value = 1 + count::value; + }; + + template<> + struct count<> { + static const unsigned value = 0; + }; + + template struct unsigned_c { }; + + template + unsigned_c::value> f(); + + void test_f() { + unsigned_c<0> uc0a = f(); // okay, deduced to an empty pack + unsigned_c<0> uc0b = f<>(); + unsigned_c<1> uc1 = f(); + unsigned_c<2> uc2 = f(); + } +} diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp new file mode 100644 index 0000000..de3b44f --- /dev/null +++ b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// PR5811 +template void Call(F f) { f(1); } +template void f(T); +void a() { Call(f); } + +// Check the conversion of a template-id to a pointer +template struct Constant { }; +Constant > constant0; + +template void constant_func(); +void test_constant_func() { + constant_func >(); +} + + +// Check typeof() on a template-id referring to a single function +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; + +int typeof0[is_same<__typeof__(f), void (int)>::value? 1 : -1]; +int typeof1[is_same<__typeof__(&f), void (*)(int)>::value? 1 : -1]; + +template void g(T); // expected-note{{possible target for call}} +template void g(T, T); // expected-note{{possible target for call}} + +int typeof2[is_same<__typeof__(g), void (int)>::value? 1 : -1]; // \ + // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}} diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp new file mode 100644 index 0000000..5556f35 --- /dev/null +++ b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp @@ -0,0 +1,65 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template X f(Y,Z); // expected-note {{candidate template ignored: couldn't infer template argument 'X'}} + +void g() { + f("aa",3.0); // expected-warning{{conversion from string literal to 'char *' is deprecated}} + f("aa",3.0); // Z is deduced to be double \ + // expected-warning{{conversion from string literal to 'char *' is deprecated}} + f("aa",3.0); // Y is deduced to be char*, and + // Z is deduced to be double + f("aa",3.0); // expected-error{{no matching}} +} + +// PR5910 +namespace PR5910 { + template + void Func() {} + + template + void Foo(R (*fp)()); + + void Test() { + Foo(Func); + } +} + +// PR5949 +namespace PR5949 { + struct Bar; + + template + void quuz(const Container &cont) { + } + + template + int Foo(Bar *b, void (*Baz)(const T &t), T * = 0) { + return 0; + } + + template + int Quux(Bar *b, T * = 0) + { + return Foo(b, quuz); + } +} + +// PR7641 +namespace PR7641 { + namespace N2 + { + template + int f0(int); + } + namespace N + { + using N2::f0; + } + + template + int + f1(R(a)(B1)); + + void f2() + { f1(N::f0); } +} diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp new file mode 100644 index 0000000..81addfe --- /dev/null +++ b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp @@ -0,0 +1,68 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +// Metafunction to extract the Nth type from a set of types. +template struct get_nth_type; + +template +struct get_nth_type : get_nth_type { }; + +template +struct get_nth_type<0, Head, Tail...> { + typedef Head type; +}; + +// Placeholder type when get_nth_type fails. +struct no_type {}; + +template +struct get_nth_type { + typedef no_type type; +}; + +template +typename get_nth_type<0, Args...>::type first_arg(Args...); + +template +typename get_nth_type<1, Args...>::type second_arg(Args...); + +// Test explicit specification of function template arguments. +void test_explicit_spec_simple() { + int *ip1 = first_arg(0); + int *ip2 = first_arg(0, 0); + float *fp1 = first_arg(0, 0, 0); +} + +// Template argument deduction can extend the sequence of template +// arguments corresponding to a template parameter pack, even when the +// sequence contains explicitly specified template arguments. +void test_explicit_spec_extension(double *dp) { + int *ip1 = first_arg(0, 0); + int *ip2 = first_arg(0, 0, 0, 0); + float *fp1 = first_arg(0, 0, 0); + int *i1 = second_arg(0, (int*)0, 0); + double *dp1 = first_arg<>(dp); +} + +template +struct tuple { }; + +template +void accept_tuple(tuple); + +void test_explicit_spec_extension_targs(tuple t3) { + accept_tuple(t3); + accept_tuple(t3); + accept_tuple(t3); + accept_tuple(t3); +} + +template +void accept_function_ptr(R(*)(ParmTypes...)); + +void test_explicit_spec_extension_funcparms(int (*f3)(int, float, double)) { + accept_function_ptr(f3); + accept_function_ptr(f3); + accept_function_ptr(f3); + accept_function_ptr(f3); + accept_function_ptr(f3); +} -- cgit v1.2.3