aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp23/elision2.C
blob: a698fc9f3abf98ae186320d2f298c2f45d87c48a (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
// PR c++/101165 - P2266R1 - Simpler implicit move
// { dg-do compile { target c++20 } }
// Test from P2266R1, $ 3.3. Two overload resolutions are overly confusing.

struct Widget {
    Widget();
    Widget(Widget&&);
};

struct Frodo {
    Frodo(Widget&);
    Frodo(Widget&&) = delete;
};

struct Sam {
    Sam(Widget&) = delete; // #1
    Sam(const Widget&);  // #2
};

Sam twelve() {
    Widget w;
    // This is supposed to call #2 since C++20 because P1155.
    // But we actually choose #1 since r11-2411 (in C++20 only).
    return w; // { dg-error "deleted" "" { target c++20_only } }
}

Frodo thirteen() {
    Widget w;
    // This is a correct error in both C++20 and C++23.
    return w;  // { dg-error "use of deleted function" }
}

struct Merry {};
struct Pippin {};
struct Together : Merry, Pippin {};
struct Quest {
    Quest(Merry&&);
    Quest(Pippin&&);
    Quest(Together&);
};

Quest fourteen() {
  Together t;
  // C++20: calls Quest(Together&).  Proposed: ill-formed.
  return t; // { dg-error "ambiguous" "" { target c++23 } }
}