1 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5 
6 #if __cplusplus < 201103L
7 // expected-error@+1 {{variadic macro}}
8 #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
9 #endif
10 
11 namespace dr2103 { // dr2103: yes
f()12   void f() {
13     int a;
14     int &r = a; // expected-note {{here}}
15     struct Inner {
16       void f() {
17         int &s = r; // expected-error {{enclosing function}}
18         (void)s;
19       }
20     };
21   }
22 }
23 
24 namespace dr2120 { // dr2120: 7
25   struct A {};
26   struct B : A {};
27   struct C { A a; };
28   struct D { C c[5]; };
29   struct E : B { D d; };
30   static_assert(__is_standard_layout(B), "");
31   static_assert(__is_standard_layout(D), "");
32   static_assert(!__is_standard_layout(E), "");
33 }
34 
35 namespace dr2140 { // dr2140: 9
36 #if __cplusplus >= 201103L
37   union U { int a; decltype(nullptr) b; };
test(U u)38   constexpr int *test(U u) {
39     return u.b;
40   }
41   static_assert(!test({123}), "u.b should be valid even when b is inactive");
42 #endif
43 }
44 
45 namespace dr2170 { // dr2170: 9
46 #if __cplusplus >= 201103L
f()47   void f() {
48     constexpr int arr[3] = {1, 2, 3}; // expected-note {{here}}
49     struct S {
50       int get(int n) { return arr[n]; }
51       const int &get_ref(int n) { return arr[n]; } // expected-error {{enclosing function}}
52       // FIXME: expected-warning@-1 {{reference to stack}}
53     };
54   }
55 #endif
56 }
57 
58 namespace dr2180 { // dr2180: yes
59   class A {
60     A &operator=(const A &); // expected-note 0-2{{here}}
61     A &operator=(A &&); // expected-note 0-2{{here}} expected-error 0-1{{extension}}
62   };
63 
64   struct B : virtual A {
65     B &operator=(const B &);
66     B &operator=(B &&); // expected-error 0-1{{extension}}
67     virtual void foo() = 0;
68   };
69 #if __cplusplus < 201103L
70   B &B::operator=(const B&) = default; // expected-error {{private member}} expected-error {{extension}} expected-note {{here}}
71   B &B::operator=(B&&) = default; // expected-error {{private member}} expected-error 2{{extension}} expected-note {{here}}
72 #else
73   B &B::operator=(const B&) = default; // expected-error {{would delete}} expected-note@-9{{inaccessible copy assignment}}
74   B &B::operator=(B&&) = default; // expected-error {{would delete}} expected-note@-10{{inaccessible move assignment}}
75 #endif
76 }
77