brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · 45ce0dc Raw
160 lines · cpp
1// REQUIRES: x86-registered-target2// RUN: %clang_cc1 %s -S -triple=x86_64 -mllvm -sort-timers=0 -o - -ftime-report  2>&1 | FileCheck %s3// RUN: %clang_cc1 %s -S -triple=x86_64 -mllvm -sort-timers=0 -o - -fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING -ftime-report  2>&1 | FileCheck %s4 5// Template function declarations6template <typename T>7void foo();8template <typename T, typename U>9void foo();10 11// Template function definitions.12template <typename T>13void foo() {}14 15// Template class (forward) declarations16template <typename T>17struct A;18template <typename T, typename U>19struct b;20template <typename>21struct C;22template <typename, typename>23struct D;24 25// Forward declarations with default parameters?26template <typename T = int>27class X1;28template <typename = int>29class X2;30 31// Forward declarations w/template template parameters32template <template <typename> class T>33class TTP1;34template <template <typename> class>35class TTP2;36template <template <typename X, typename Y> class T>37class TTP5;38 39// Forward declarations with non-type params40template <int>41class NTP0;42template <int N>43class NTP1;44template <int N = 5>45class NTP2;46template <int = 10>47class NTP3;48template <unsigned int N = 12u>49class NTP4;50template <unsigned int = 12u>51class NTP5;52template <unsigned = 15u>53class NTP6;54template <typename T, T Obj>55class NTP7;56 57// Template class declarations58template <typename T>59struct A {};60template <typename T, typename U>61struct B {};62 63namespace PR6184 {64namespace N {65template <typename T>66void bar(typename T::x);67}68 69template <typename T>70void N::bar(typename T::x) {}71}72 73// This PR occurred only in template parsing mode.74namespace PR17637 {75template <int>76struct L {77  template <typename T>78  struct O {79    template <typename U>80    static void Fun(U);81  };82};83 84template <int k>85template <typename T>86template <typename U>87void L<k>::O<T>::Fun(U) {}88 89void Instantiate() { L<0>::O<int>::Fun(0); }90}91 92namespace explicit_partial_specializations {93typedef char (&oneT)[1];94typedef char (&twoT)[2];95typedef char (&threeT)[3];96typedef char (&fourT)[4];97typedef char (&fiveT)[5];98typedef char (&sixT)[6];99 100char one[1];101char two[2];102char three[3];103char four[4];104char five[5];105char six[6];106 107template <bool b>108struct bool_ { typedef int type; };109template <>110struct bool_<false> {};111 112#define XCAT(x, y) x##y113#define CAT(x, y) XCAT(x, y)114#define sassert(_b_) bool_<(_b_)>::type CAT(var, __LINE__);115 116template <int>117struct L {118  template <typename T>119  struct O {120    template <typename U>121    static oneT Fun(U);122  };123};124template <int k>125template <typename T>126template <typename U>127oneT L<k>::O<T>::Fun(U) { return one; }128 129template <>130template <>131template <typename U>132oneT L<0>::O<char>::Fun(U) { return one; }133 134void Instantiate() {135  sassert(sizeof(L<0>::O<int>::Fun(0)) == sizeof(one));136  sassert(sizeof(L<0>::O<char>::Fun(0)) == sizeof(one));137}138}139 140template <class>141struct Foo {142  template <class _Other>143  using rebind_alloc = _Other;144};145template <class _Alloc>146struct _Wrap_alloc {147  template <class _Other>148  using rebind_alloc = typename Foo<_Alloc>::template rebind_alloc<_Other>;149  template <class>150  using rebind = _Wrap_alloc;151};152_Wrap_alloc<int>::rebind<int> w;153 154// CHECK: Clang time report155// CHECK:      Front end156// CHECK-NEXT: LLVM IR generation157// CHECK-NEXT: Machine code generation158// CHECK-NEXT: Optimizer159// CHECK-NEXT: Total160