[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / test / CXX / drs / dr17xx.cpp
blobe91f4a6d69b3ac94476490c368b1646b763d2ab1
1 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6 namespace dr1715 { // dr1715: 3.9
7 #if __cplusplus >= 201103L
8 struct B {
9 template<class T> B(T, typename T::Q);
12 class S {
13 using Q = int;
14 template<class T> friend B::B(T, typename T::Q);
17 struct D : B {
18 using B::B;
20 struct E : B { // expected-note 2{{candidate}}
21 template<class T> E(T t, typename T::Q q) : B(t, q) {} // expected-note {{'Q' is a private member}}
24 B b(S(), 1);
25 D d(S(), 2);
26 E e(S(), 3); // expected-error {{no match}}
27 #endif
30 namespace dr1722 { // dr1722: 9
31 #if __cplusplus >= 201103L
32 void f() {
33 const auto lambda = [](int x) { return x + 1; };
34 // Without the DR applied, this static_assert would fail.
35 static_assert(
36 noexcept((int (*)(int))(lambda)),
37 "Lambda-to-function-pointer conversion is expected to be noexcept");
39 #endif
40 } // namespace dr1722
42 namespace dr1734 { // dr1734: no
43 #if __cplusplus >= 201103L
44 struct A {
45 A(const A&) = delete;
47 // FIXME: 'A' should not be trivially copyable because the class lacks at least
48 // one non-deleted copy constructor, move constructor, copy assignment
49 // operator, or move assignment operator.
50 static_assert(__is_trivially_copyable(A), "");
51 #endif
54 namespace dr1736 { // dr1736: 3.9
55 #if __cplusplus >= 201103L
56 struct S {
57 template <class T> S(T t) {
58 struct L : S {
59 using S::S;
61 typename T::type value; // expected-error {{no member}}
62 L l(value); // expected-note {{instantiation of}}
65 struct Q { typedef int type; } q;
66 S s(q); // expected-note {{instantiation of}}
67 #endif
70 namespace dr1753 { // dr1753: 11
71 typedef int T;
72 struct A { typedef int T; };
73 namespace B { typedef int T; }
75 void f(T n) {
76 n.~T();
77 n.T::~T();
79 n.dr1753::~T(); // expected-error {{'dr1753' does not refer to a type name in pseudo-destructor}}
80 n.dr1753::T::~T();
82 n.A::~T(); // expected-error {{the type of object expression ('T' (aka 'int')) does not match the type being destroyed ('A') in pseudo-destructor expression}}
83 n.A::T::~T();
85 n.B::~T(); // expected-error {{'B' does not refer to a type name in pseudo-destructor expression}}
86 n.B::T::~T();
88 #if __cplusplus >= 201103L
89 n.decltype(n)::~T(); // expected-error {{not a class, namespace, or enumeration}}
90 n.T::~decltype(n)(); // expected-error {{expected a class name after '~'}}
91 n.~decltype(n)(); // OK
92 #endif
96 namespace dr1756 { // dr1756: 3.7
97 #if __cplusplus >= 201103L
98 // Direct-list-initialization of a non-class object
100 int a{0};
102 struct X { operator int(); } x;
103 int b{x};
104 #endif
107 namespace dr1758 { // dr1758: 3.7
108 #if __cplusplus >= 201103L
109 // Explicit conversion in copy/move list initialization
111 struct X { X(); };
112 struct Y { explicit operator X(); } y;
113 X x{y};
115 struct A {
116 A() {}
117 A(const A &) {}
119 struct B {
120 operator A() { return A(); }
121 } b;
122 A a{b};
123 #endif
126 namespace dr1762 { // dr1762: 14
127 #if __cplusplus >= 201103L
128 float operator ""_E(const char *);
129 // expected-error@+2 {{invalid suffix on literal; C++11 requires a space between literal and identifier}}
130 // expected-warning@+1 {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
131 float operator ""E(const char *);
132 #endif
135 namespace dr1778 { // dr1778: 9
136 // Superseded by P1286R2.
137 #if __cplusplus >= 201103L
138 struct A { A() noexcept(true) = default; };
139 struct B { B() noexcept(false) = default; };
140 static_assert(noexcept(A()), "");
141 static_assert(!noexcept(B()), "");
143 struct C { A a; C() noexcept(false) = default; };
144 struct D { B b; D() noexcept(true) = default; };
145 static_assert(!noexcept(C()), "");
146 static_assert(noexcept(D()), "");
147 #endif