blob: efd07c617e528615296ffe17a1c84ddc011084bd [file] [log] [blame]
Richard Smith5de91b52013-06-25 01:25:15 +00001@import cxx_templates_common;
2
Richard Smith8f8f05c2013-06-24 04:45:28 +00003template<typename T> T f();
4template<typename T> T f(T t) { return t; }
5namespace N {
6 template<typename T> T f();
7 template<typename T> T f(T t) { return t; }
8}
Richard Smithbf78e642013-06-24 22:51:00 +00009
10template<typename> int template_param_kinds_1();
11template<template<typename, int, int...> class> int template_param_kinds_2();
12template<template<typename T, typename U, U> class> int template_param_kinds_3();
Richard Smith5de91b52013-06-25 01:25:15 +000013
14template<typename T> struct SomeTemplate<T&> {};
15template<typename T> struct SomeTemplate<T&>;
16typedef SomeTemplate<int&> SomeTemplateIntRef;
Richard Smith0e5d7b82013-07-25 23:08:39 +000017
18extern DefinedInCommon &defined_in_common;
19
Richard Smithd46d6de2013-10-13 23:50:45 +000020template<int> struct MergeTemplates;
21MergeTemplates<0> *merge_templates_b;
22
Richard Smithdc5523d2014-07-11 00:20:06 +000023template<typename T> template<typename U>
24constexpr int Outer<T>::Inner<U>::g() { return 2; }
25static_assert(Outer<int>::Inner<int>::g() == 2, "");
26
Richard Smith0e5d7b82013-07-25 23:08:39 +000027@import cxx_templates_b_impl;
28
29template<typename T, typename> struct Identity { typedef T type; };
30template<typename T> void UseDefinedInBImpl() {
31 typename Identity<DefinedInBImpl, T>::type dependent;
32 FoundByADL(dependent);
33 typename Identity<DefinedInBImpl, T>::type::Inner inner;
34 dependent.f();
35}
36
37extern DefinedInBImpl &defined_in_b_impl;
38
Richard Smith7ecc31b2013-08-02 01:09:12 +000039template<typename T>
40struct RedeclareTemplateAsFriend {
41 template<typename U>
42 friend struct RedeclaredAsFriend;
43};
44
Richard Smithd55889a2013-09-09 16:55:27 +000045void use_some_template_b() {
46 SomeTemplate<char[1]> a;
47 SomeTemplate<char[2]> b, c;
48 b = c;
49}
50
Richard Smith01a73372013-10-15 22:02:41 +000051auto enum_b_from_b = CommonTemplate<int>::b;
52const auto enum_c_from_b = CommonTemplate<int>::c;
53
54template<int> struct UseInt;
55template<typename T> void UseRedeclaredEnum(UseInt<T() + CommonTemplate<char>::a>);
56constexpr void (*UseRedeclaredEnumB)(UseInt<1>) = UseRedeclaredEnum<int>;
57
Richard Smith0c1065f2013-10-15 23:19:58 +000058template<typename> struct MergeSpecializations;
59template<typename T> struct MergeSpecializations<T&> {
60 typedef int partially_specialized_in_b;
61};
62template<> struct MergeSpecializations<double> {
63 typedef int explicitly_specialized_in_b;
64};
65
Richard Smith0e5d7b82013-07-25 23:08:39 +000066@import cxx_templates_a;
67template<typename T> void UseDefinedInBImplIndirectly(T &v) {
68 PerformDelayedLookup(v);
69}
70
71void TriggerInstantiation() {
72 UseDefinedInBImpl<void>();
Richard Smith561e0dc2014-03-23 19:45:26 +000073 Std::f<int>();
Richard Smith0e5d7b82013-07-25 23:08:39 +000074}