brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 7de7f50 Raw
200 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -std=c++20 %s2 3namespace GH39811 {4 5template<int = 0> class C {};6 7C (a);8C (b) = C();9C (c) {};10C (((((d)))));11 12template<C (e)> class X;13template<C (...f)> class Y;14 15void test() {16    C (g);17    C (h) = C();18    C (i) {};19    (void)g;20    (void)h;21    (void)i;22}23 24C* (bad1); // expected-error {{cannot form pointer to deduced class template specialization type}}25C (*bad2); // expected-error {{cannot form pointer to deduced class template specialization type}}26 27}28 29namespace GH64347 {30 31template<typename X, typename Y> struct A { X x; Y y;};32void test() {33   A(1, 2);34   new A(1, 2);35}36 37template<A a>38void f() { (void)a; }39void k() {40  // Test CTAD works for non-type template arguments.41  f<A(0, 0)>();42}43 44} // namespace GH6434745 46namespace GH123591 {47 48 49template < typename... _Types >50struct variant {51  template <int N = sizeof...(_Types)>52  variant(_Types...);53};54 55template <class T>56using AstNode = variant<T, T, T>;57 58AstNode tree(42, 43, 44);59 60}61 62namespace GH123591_2 {63 64template <int>65using enable_if_t = char;66 67template < typename... Types >68struct variant {69  template < enable_if_t<sizeof...(Types)>>70  variant();71};72 73template <int>74using AstNode = variant<>;75// expected-note@-1 {{couldn't infer template argument ''}} \76// expected-note@-1 2{{implicit deduction guide declared as}} \77// expected-note@-1 {{candidate function template not viable}}78 79 80AstNode tree; // expected-error {{no viable constructor or deduction guide}}81 82}83 84namespace GH127539 {85 86template <class...>87struct A {88    template <class... ArgTs>89    A(ArgTs...) {}90};91 92template <class... ArgTs>93A(ArgTs...) -> A<typename ArgTs::value_type...>;94 95template <class... Ts>96using AA = A<Ts..., Ts...>;97 98AA a{};99 100}101 102namespace GH129077 {103 104using size_t = decltype(sizeof(0));105 106struct index_type107{108  size_t value = 0;109  index_type() = default;110  constexpr index_type(size_t i) noexcept : value(i) {}111};112 113template <index_type... Extents>114struct extents115{116  constexpr extents(decltype(Extents)...) noexcept {}117};118 119template <class... Extents>120extents(Extents...) -> extents<(requires { Extents::value; } ? Extents{} : ~0ull)...>;121 122template <index_type... Index>123using index = extents<Index...>;124 125int main()126{127  extents i{0,0};128  auto j = extents<64,{}>({}, 42);129 130  index k{0,0};131  auto l = index<64,{}>({}, 42);132 133  return 0;134}135 136}137 138namespace GH129620 {139 140template <class... Ts>141struct A {142    constexpr A(Ts...) {}143};144 145template <class... Ts>146using Foo = A<Ts...>;147 148template <class T>149using Bar = Foo<T, T>;150 151Bar a{0, 0};152 153}154 155namespace GH129998 {156 157struct converible_to_one {158    constexpr operator int() const noexcept { return 1; }159};160 161template <int... Extents>162struct class_template {163    class_template() = default;164    constexpr class_template(auto&&...) noexcept {}165};166 167template <class... Extents>168class_template(Extents...) -> class_template<(true ? 0 : +Extents{})...>;169 170template <int... Extents>171using alias_template = class_template<Extents...>;172 173alias_template var2{converible_to_one{}, 2};174 175}176 177namespace GH136624 {178  // expected-note@+1 2{{no known conversion}}179  template<typename U> struct A {180    U t;181  };182 183  template<typename V> A(V) -> A<V>;184 185  namespace foo {186    template<class Y> using Alias = A<Y>;187  }188 189  // FIXME: This diagnostic is missing 'foo::Alias', as written.190  foo::Alias t = 0;191  // expected-error@-1 {{no viable conversion from 'int' to 'GH136624::A<int>' (aka 'A<int>')}}192} // namespace GH136624193 194namespace GH131342 {195  template <class> constexpr int val{0};196  template <class T, int> struct A { A(T) {} };197  template <class T> using AA = A<T, val<T>>;198  AA a{0};199} // namespace GH131342200