Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Modules / Inputs / cxx-templates-a.h
blob4340910d1e2a40d1a2b22d1b5ff99cd0fa75fb9b
1 @import cxx_templates_common;
3 template<typename T> T f() { return T(); }
4 template<typename T> T f(T);
5 namespace N {
6 template<typename T> T f() { return T(); }
7 template<typename T> T f(T);
10 template<int N> int template_param_kinds_1();
11 template<template<typename T, int, int> class> int template_param_kinds_2();
12 template<template<typename T, typename U, T> class> int template_param_kinds_3();
14 template<typename T> struct SomeTemplate<T*>;
15 template<typename T> struct SomeTemplate<T*> {};
16 typedef SomeTemplate<int*> SomeTemplateIntPtr;
18 template<typename T> void PerformDelayedLookup(T &t) {
19 t.f();
20 typename T::Inner inner;
21 FoundByADL(t);
24 template<typename T> void PerformDelayedLookupInDefaultArgument(T &t, int a = (FoundByADL(T()), 0)) {}
26 template<typename T> struct RedeclaredAsFriend {};
28 void use_some_template_a() {
29 SomeTemplate<char[2]> a;
30 SomeTemplate<char[1]> b, c;
31 b = c;
33 (void)&WithImplicitSpecialMembers<int>::n;
36 template<int> struct MergeTemplates;
37 MergeTemplates<0> *merge_templates_a;
39 auto enum_a_from_a = CommonTemplate<int>::a;
40 const auto enum_c_from_a = CommonTemplate<int>::c;
42 template<int> struct UseInt;
43 template<typename T> void UseRedeclaredEnum(UseInt<T() + CommonTemplate<char>::a>);
44 constexpr void (*UseRedeclaredEnumA)(UseInt<1>) = UseRedeclaredEnum<int>;
46 template<typename> struct MergeSpecializations;
47 template<typename T> struct MergeSpecializations<T*> {
48 typedef int partially_specialized_in_a;
50 template<> struct MergeSpecializations<char> {
51 typedef int explicitly_specialized_in_a;
54 void InstantiateWithFriend(Std::WithFriend<int> wfi) {}
56 template<typename T> struct WithPartialSpecialization<T*> {
57 typedef int type;
58 T &f() { static T t; return t; }
60 typedef WithPartialSpecializationUse::type WithPartialSpecializationInstantiate;
61 typedef WithPartialSpecialization<void(int)>::type WithPartialSpecializationInstantiate2;
63 template<> struct WithExplicitSpecialization<int> {
64 int n;
65 template<typename T> T &inner_template() {
66 return n;
70 template<typename T> template<typename U>
71 constexpr int Outer<T>::Inner<U>::f() { return 1; }
72 static_assert(Outer<int>::Inner<int>::f() == 1, "");
74 template<typename T> struct MergeTemplateDefinitions {
75 static constexpr int f();
76 static constexpr int g();
78 template<typename T> constexpr int MergeTemplateDefinitions<T>::f() { return 1; }
80 template<typename T> using AliasTemplate = T;
82 template<typename T> struct PartiallyInstantiatePartialSpec {};
83 template<typename T> struct PartiallyInstantiatePartialSpec<T*> {
84 static T *foo() { return reinterpret_cast<T*>(0); }
85 static T *bar() { return reinterpret_cast<T*>(0); }
87 typedef PartiallyInstantiatePartialSpec<int*> PartiallyInstantiatePartialSpecHelper;
89 void InstantiateWithAliasTemplate(WithAliasTemplate<int>::X<char>);
90 inline int InstantiateWithAnonymousDeclsA(WithAnonymousDecls<int> x) { return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e; }
91 inline int InstantiateWithAnonymousDeclsB2(WithAnonymousDecls<char> x);
94 template<typename T1 = int>
95 struct MergeAnonUnionMember {
96 MergeAnonUnionMember() { (void)values.t1; }
97 union { int t1; } values;
99 inline MergeAnonUnionMember<> maum_a() { return {}; }
101 template<typename T> struct DontWalkPreviousDeclAfterMerging { struct Inner { typedef T type; }; };
103 namespace TestInjectedClassName {
104 template<typename T> struct X { X(); };
105 typedef X<char[1]> A;