brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · 50dedb1 Raw
226 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s2// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s3// expected-no-diagnostics4 5namespace pr12262 {6 7template<typename T, typename... Ts>8void abc1(int (*xxx)[sizeof ... (Ts) + 1]);9 10void qq1 () {11  abc1<int>(0);12  abc1<int,double>(0);13}14 15 16template <unsigned N> class array {};17 18 19template<typename T, typename... Types>20array<sizeof...(Types)> make_array1(Types&&... args);21 22void qq2 () {23  array<1> arr = make_array1<int>(1);24  array<3> arr2 = make_array1<int>(1,array<5>(),0.1);25}26 27 28template<typename T, typename... Types>29int make_array(array<sizeof...(Types)>&, Types... args);30 31void qq3 () {32  array<1> a1;33  int aa1 = make_array<int>(a1,1);34  array<2> a2;35  int aa2 = make_array<int>(a2, 0L, "abc");36}37 38 39template<typename ... Ts>40struct AAA {41  template<typename T, typename... Types>42  static array<sizeof...(Types)> make_array(Types ... args);43};44 45void qq4 () {46  array<2> arr2 = AAA<int, int>::make_array<int>(1,2);47}48 49}50 51 52namespace pr12439 {53 54template<class... Members>55struct X {56  template<int Idx>57  using get_t = decltype(sizeof...(Members));58 59  template<int i>60  get_t<i> get();61};62 63template<class... Members>64template<int i>65typename X<Members...>::template get_t<i> X<Members...>::get()66{67  return 0;68}69 70}71 72 73namespace pr13272 {74 75template<bool B, class T = void>76struct enable_if { };77 78template<class T> struct enable_if<true, T> {79  typedef T type;80};81 82class Exception {};83 84template<class Ex, typename... Args>85void cxx_throw(typename enable_if<(sizeof...(Args) > 0), const char *>::type fmt, Args&&... args) {86  return;87}88 89void test() {90  cxx_throw<Exception>("Youpi",1);91}92 93}94 95 96namespace pr13817 {97 98template <unsigned>99struct zod;100 101template <>102struct zod<1> {};103 104template <typename T, typename ... Ts>105zod<sizeof...(Ts)> make_zod(Ts ...) {106  return zod<sizeof...(Ts)>();107}108 109int main(int argc, char *argv[])110{111  make_zod<int>(1);112  return 0;113}114 115}116 117 118namespace pr14273 {119 120template<typename T, int i>121struct myType122{ };123 124template<typename T, typename... Args>125struct Counter126{127  static const int count = 1 + Counter<Args...>::count;128};129 130template<typename T>131struct Counter<T>132{133  static const int count = 1;134};135 136template<typename Arg, typename... Args>137myType<Arg, sizeof...(Args)>* make_array_with_type(const Args&... args)138{139  return 0;140}141 142void func(void)143{144  make_array_with_type<char>(1,2,3);145}146 147}148 149 150namespace pr15112151{152  template<bool, typename _Tp = void>153    struct enable_if154    { };155  template<typename _Tp>156    struct enable_if<true,_Tp>157    { typedef _Tp type; };158 159  typedef __typeof__(sizeof(int)) size_t;160 161  template <size_t n, typename T, typename... Args>162  struct is_array_of { static const bool value = true; };163 164  struct cpu { using value_type = void; };165 166  template <size_t Order, typename T>167  struct coords_alias { typedef T type; };168 169  template <size_t Order, typename MemoryTag>170  using coords = typename coords_alias<Order, MemoryTag>::type;171 172  template <typename MemTag, typename... Args>173  typename enable_if<is_array_of<sizeof...(Args), size_t, Args...>::value,174                     coords<sizeof...(Args), MemTag>>::type175    mkcoords(Args... args);176 177  auto c1 = mkcoords<cpu>(0ul, 0ul, 0ul);178}179 180 181namespace pr12699 {182 183template<bool B>184struct bool_constant185{186  static const bool value = B;187};188 189template<typename... A>190struct F191{192  template<typename... B>193    using SameSize = bool_constant<sizeof...(A) == sizeof...(B)>;194 195  template<typename... B, typename = SameSize<B...>>196  F(B...) { }197};198 199void func()200{201  F<int> f1(3);202}203 204}205 206#if __cplusplus >= 202002L207namespace GH81436 {208 209template <class E> struct Bar;210 211template <class E>212Bar(E) -> Bar<E>;213 214template <int> struct Foo {};215 216// Bar<Ts> doesn't have to be of a complete type.217template <class... Ts>218auto func() requires requires(Bar<Ts> ...init_lists) {219  sizeof...(init_lists) > 0;220} {}221 222void f() { func<int>(); }223 224} // namespace GH81436225#endif226