aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/class-deduction108.C
blob: e82c4bafb048ff83a6b5fda288a2132ea966a608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// PR c++/102137
// { dg-do compile { target c++17 } }

template<class T>
struct A {
  constexpr A() { }
  constexpr A(int) { }
};

explicit A(...) -> A<int>;

template<template<class> class TT>
void f() {
  TT x1 = 0; // { dg-error "deduction|no match" }
  TT x2 = {0}; // { dg-error "explicit deduction guide" }
  TT x3(0);
  TT x4{0};
  TT x5;
  new TT(0);
  new TT{0};
  new TT();
  new TT{};
  new TT;
}

template<class T>
void g(T t) {
  A a1 = t; // { dg-error "deduction|no match" }
  A a2 = {t}; // { dg-error "explicit deduction guide" }
  A a3(t);
  A a4{t};
  A a5;
  new A(t);
  new A{t};
}

template void f<A>();
template void g(int);

template<template<class> class TT>
struct B {
  static inline TT x1 = 0; // { dg-error "deduction|no match" }
  static inline TT x2 = {0}; // { dg-error "explicit deduction guide" }
  static inline TT x4{0};
  static inline TT x5;
};

template<class T>
struct C {
  static inline T t;
  static inline A a1 = t; // { dg-error "deduction|no match" }
  static inline A a2 = {t}; // { dg-error "explicit deduction guide" }
  static inline A a4{t};
  static inline A a5{};
};

template struct B<A>;
template struct C<int>;

template<template<class> class TT>
struct E {
  static constexpr TT x1 = 0; // { dg-error "deduction|no match" }
  static constexpr TT x2 = {0}; // { dg-error "explicit deduction guide" }
  static constexpr TT x4{0};
  static constexpr TT x5{};
};

template<class T>
struct F {
  static constexpr T t{};
  static constexpr A a1 = t; // { dg-error "deduction|no match" }
  static constexpr A a2 = {t}; // { dg-error "explicit deduction guide" }
  static constexpr A a4{t};
  static constexpr A a5{};
};

template struct E<A>;
template struct F<int>;