dr21xx.cpp
2.55 KB
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
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
#if __cplusplus < 201103L
// expected-error@+1 {{variadic macro}}
#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
#endif
namespace dr2103 { // dr2103: yes
void f() {
int a;
int &r = a; // expected-note {{here}}
struct Inner {
void f() {
int &s = r; // expected-error {{enclosing function}}
(void)s;
}
};
}
}
namespace dr2120 { // dr2120: 7
struct A {};
struct B : A {};
struct C { A a; };
struct D { C c[5]; };
struct E : B { D d; };
static_assert(__is_standard_layout(B), "");
static_assert(__is_standard_layout(D), "");
static_assert(!__is_standard_layout(E), "");
}
namespace dr2140 { // dr2140: 9
#if __cplusplus >= 201103L
union U { int a; decltype(nullptr) b; };
constexpr int *test(U u) {
return u.b;
}
static_assert(!test({123}), "u.b should be valid even when b is inactive");
#endif
}
namespace dr2170 { // dr2170: 9
#if __cplusplus >= 201103L
void f() {
constexpr int arr[3] = {1, 2, 3}; // expected-note {{here}}
struct S {
int get(int n) { return arr[n]; }
const int &get_ref(int n) { return arr[n]; } // expected-error {{enclosing function}}
// FIXME: expected-warning@-1 {{reference to stack}}
};
}
#endif
}
namespace dr2180 { // dr2180: yes
class A {
A &operator=(const A &); // expected-note 0-2{{here}}
A &operator=(A &&); // expected-note 0-2{{here}} expected-error 0-1{{extension}}
};
struct B : virtual A {
B &operator=(const B &);
B &operator=(B &&); // expected-error 0-1{{extension}}
virtual void foo() = 0;
};
#if __cplusplus < 201103L
B &B::operator=(const B&) = default; // expected-error {{private member}} expected-error {{extension}} expected-note {{here}}
B &B::operator=(B&&) = default; // expected-error {{private member}} expected-error 2{{extension}} expected-note {{here}}
#else
B &B::operator=(const B&) = default; // expected-error {{would delete}} expected-note@-9{{inaccessible copy assignment}}
B &B::operator=(B&&) = default; // expected-error {{would delete}} expected-note@-10{{inaccessible move assignment}}
#endif
}