2014-12-11 04:04:48 +08:00
|
|
|
// 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
|
2018-04-06 02:55:37 +08:00
|
|
|
// expected-error@+1 {{variadic macro}}
|
|
|
|
#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
|
2014-12-11 04:04:48 +08:00
|
|
|
#endif
|
|
|
|
|
2018-04-06 02:55:37 +08:00
|
|
|
namespace dr1813 { // dr1813: 7
|
|
|
|
struct B { int i; };
|
|
|
|
struct C : B {};
|
|
|
|
struct D : C {};
|
|
|
|
struct E : D { char : 4; };
|
|
|
|
|
|
|
|
static_assert(__is_standard_layout(B), "");
|
|
|
|
static_assert(__is_standard_layout(C), "");
|
|
|
|
static_assert(__is_standard_layout(D), "");
|
|
|
|
static_assert(!__is_standard_layout(E), "");
|
|
|
|
|
|
|
|
struct Q {};
|
|
|
|
struct S : Q {};
|
|
|
|
struct T : Q {};
|
|
|
|
struct U : S, T {};
|
|
|
|
|
|
|
|
static_assert(__is_standard_layout(Q), "");
|
|
|
|
static_assert(__is_standard_layout(S), "");
|
|
|
|
static_assert(__is_standard_layout(T), "");
|
|
|
|
static_assert(!__is_standard_layout(U), "");
|
|
|
|
}
|
|
|
|
|
2018-07-18 06:24:09 +08:00
|
|
|
namespace dr1815 { // dr1815: no
|
|
|
|
#if __cplusplus >= 201402L
|
|
|
|
// FIXME: needs codegen test
|
|
|
|
struct A { int &&r = 0; }; // FIXME expected-warning {{not supported}}
|
|
|
|
A a = {}; // expected-note {{here}}
|
|
|
|
|
|
|
|
struct B { int &&r = 0; }; // expected-error {{binds to a temporary}} expected-note {{here}}
|
|
|
|
B b; // expected-note {{here}}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-04-06 02:55:37 +08:00
|
|
|
namespace dr1881 { // dr1881: 7
|
|
|
|
struct A { int a : 4; };
|
|
|
|
struct B : A { int b : 3; };
|
|
|
|
static_assert(__is_standard_layout(A), "");
|
|
|
|
static_assert(!__is_standard_layout(B), "");
|
|
|
|
|
|
|
|
struct C { int : 0; };
|
|
|
|
struct D : C { int : 0; };
|
|
|
|
static_assert(__is_standard_layout(C), "");
|
|
|
|
static_assert(!__is_standard_layout(D), "");
|
|
|
|
}
|
|
|
|
|
2017-01-13 08:57:54 +08:00
|
|
|
void dr1891() { // dr1891: 4
|
2014-12-11 04:04:48 +08:00
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
int n;
|
2016-11-16 08:03:24 +08:00
|
|
|
auto a = []{}; // expected-note 2{{candidate}} expected-note 2{{here}}
|
|
|
|
auto b = [=]{ return n; }; // expected-note 2{{candidate}} expected-note 2{{here}}
|
2014-12-11 04:04:48 +08:00
|
|
|
typedef decltype(a) A;
|
|
|
|
typedef decltype(b) B;
|
|
|
|
|
|
|
|
static_assert(!__has_trivial_constructor(A), "");
|
|
|
|
static_assert(!__has_trivial_constructor(B), "");
|
|
|
|
|
|
|
|
A x; // expected-error {{no matching constructor}}
|
|
|
|
B y; // expected-error {{no matching constructor}}
|
2016-11-16 08:03:24 +08:00
|
|
|
|
|
|
|
a = a; // expected-error {{copy assignment operator is implicitly deleted}}
|
|
|
|
a = static_cast<A&&>(a); // expected-error {{copy assignment operator is implicitly deleted}}
|
|
|
|
b = b; // expected-error {{copy assignment operator is implicitly deleted}}
|
|
|
|
b = static_cast<B&&>(b); // expected-error {{copy assignment operator is implicitly deleted}}
|
2014-12-11 04:04:48 +08:00
|
|
|
#endif
|
|
|
|
}
|