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++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6 // RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
9 __extension__
typedef __SIZE_TYPE__
size_t;
11 template<typename T
> struct initializer_list
{
13 initializer_list(const T
*p
, size_t n
);
17 namespace dr948
{ // dr948: 3.7
18 #if __cplusplus >= 201103L
21 constexpr A(int v
) : v(v
) { }
22 constexpr operator int() const { return v
; }
27 constexpr int id(int x
)
33 if (constexpr int i
= id(101)) { }
34 switch (constexpr int i
= id(2)) { default: break; case 2: break; }
35 for (; constexpr int i
= id(0); ) { }
36 while (constexpr int i
= id(0)) { }
38 if (constexpr A i
= 101) { }
39 switch (constexpr A i
= 2) { default: break; case 2: break; }
40 for (; constexpr A i
= 0; ) { }
41 while (constexpr A i
= 0) { }
46 namespace dr952
{ // dr952: yes
49 typedef int I
; // #dr952-typedef-decl
51 struct B
: private A
{ // #dr952-inheritance
55 I i1
; // expected-error {{private member}}
56 // expected-note@#dr952-inheritance {{constrained by private inheritance}}
57 // expected-note@#dr952-typedef-decl {{declared here}}
59 I i2
; // expected-error {{private member}}
60 // expected-note@#dr952-inheritance {{constrained by private inheritance}}
61 // expected-note@#dr952-typedef-decl {{declared here}}
63 I i3
; // expected-error {{private member}}
64 // expected-note@#dr952-inheritance {{constrained by private inheritance}}
65 // expected-note@#dr952-typedef-decl {{declared here}}
67 I i4
; // expected-error {{private member}}
68 // expected-note@#dr952-inheritance {{constrained by private inheritance}}
69 // expected-note@#dr952-typedef-decl {{declared here}}
73 } // namespace example1
80 friend int get(B
) { return x
; }
82 } // namespace example2
85 namespace dr974
{ // dr974: yes
86 #if __cplusplus >= 201103L
88 auto lam
= [](int x
= 42) { return x
; };
93 namespace dr977
{ // dr977: yes
95 #if !defined(_WIN32) || defined(__MINGW32__)
96 // expected-error@-2 {{invalid use of incomplete type 'E'}}
97 // expected-note@-3 {{definition of 'dr977::E' is not complete until the closing '}'}}
99 #if __cplusplus >= 201103L
100 enum E2
: int { e2
= E2() };
101 enum struct E3
{ e
= static_cast<int>(E3()) };
102 enum struct E4
: int { e
= static_cast<int>(E4()) };
106 namespace dr990
{ // dr990: 3.5
107 #if __cplusplus >= 201103L
108 struct A
{ // expected-note 2{{candidate}}
109 A(std::initializer_list
<int>); // expected-note {{candidate}}
115 B b2
{ 1 }; // expected-error {{no viable conversion from 'int' to 'A'}}
121 C(std::initializer_list
<int>) = delete; // expected-note {{here}}
124 C c2
[3] { 1, {2} }; // expected-error {{call to deleted}}
128 D(std::initializer_list
<int>);
129 D(std::initializer_list
<double>);